Changeset View
Changeset View
Standalone View
Standalone View
swh/indexer/storage/__init__.py
Show All 27 Lines | from .model import ( | ||||
ContentCtagsRow, | ContentCtagsRow, | ||||
ContentLanguageRow, | ContentLanguageRow, | ||||
ContentLicenseRow, | ContentLicenseRow, | ||||
ContentMetadataRow, | ContentMetadataRow, | ||||
ContentMimetypeRow, | ContentMimetypeRow, | ||||
OriginIntrinsicMetadataRow, | OriginIntrinsicMetadataRow, | ||||
RevisionIntrinsicMetadataRow, | RevisionIntrinsicMetadataRow, | ||||
) | ) | ||||
from .writer import JournalWriter | |||||
INDEXER_CFG_KEY = "indexer_storage" | INDEXER_CFG_KEY = "indexer_storage" | ||||
MAPPING_NAMES = ["codemeta", "gemspec", "maven", "npm", "pkg-info"] | MAPPING_NAMES = ["codemeta", "gemspec", "maven", "npm", "pkg-info"] | ||||
SERVER_IMPLEMENTATIONS: Dict[str, str] = { | SERVER_IMPLEMENTATIONS: Dict[str, str] = { | ||||
▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | if duplicates: | ||||
raise DuplicateId(list(map(dict, duplicates))) | raise DuplicateId(list(map(dict, duplicates))) | ||||
class IndexerStorage: | class IndexerStorage: | ||||
"""SWH Indexer Storage | """SWH Indexer Storage | ||||
""" | """ | ||||
def __init__(self, db, min_pool_conns=1, max_pool_conns=10): | def __init__(self, db, min_pool_conns=1, max_pool_conns=10, journal_writer=None): | ||||
""" | """ | ||||
Args: | Args: | ||||
db_conn: either a libpq connection string, or a psycopg2 connection | db_conn: either a libpq connection string, or a psycopg2 connection | ||||
douardda: I know this docstring was outdated before this diff, but maybe it could be updated as part of… | |||||
""" | """ | ||||
self._writer = JournalWriter(self.indexer_configuration_get, journal_writer) | |||||
try: | try: | ||||
if isinstance(db, psycopg2.extensions.connection): | if isinstance(db, psycopg2.extensions.connection): | ||||
self._pool = None | self._pool = None | ||||
self._db = Db(db) | self._db = Db(db) | ||||
else: | else: | ||||
self._pool = psycopg2.pool.ThreadedConnectionPool( | self._pool = psycopg2.pool.ThreadedConnectionPool( | ||||
min_pool_conns, max_pool_conns, db | min_pool_conns, max_pool_conns, db | ||||
) | ) | ||||
▲ Show 20 Lines • Show All 608 Lines • Show Last 20 Lines |
I know this docstring was outdated before this diff, but maybe it could be updated as part of it.