Changeset View
Changeset View
Standalone View
Standalone View
swh/lister/core/lister_base.py
Show First 20 Lines • Show All 217 Lines • ▼ Show 20 Lines | DEFAULT_CONFIG = { | ||||
'url': 'http://localhost:5002/' | 'url': 'http://localhost:5002/' | ||||
}, | }, | ||||
}), | }), | ||||
'scheduler': ('dict', { | 'scheduler': ('dict', { | ||||
'cls': 'remote', | 'cls': 'remote', | ||||
'args': { | 'args': { | ||||
'url': 'http://localhost:5008/' | 'url': 'http://localhost:5008/' | ||||
}, | }, | ||||
}) | }), | ||||
'lister': ('dict', { | |||||
'cls': 'local', | |||||
'args': { | |||||
'db': 'postgresql:///lister', | |||||
}, | |||||
}), | |||||
} | } | ||||
@property | @property | ||||
def CONFIG_BASE_FILENAME(self): # noqa: N802 | def CONFIG_BASE_FILENAME(self): # noqa: N802 | ||||
return 'lister-%s' % self.LISTER_NAME | return 'lister-%s' % self.LISTER_NAME | ||||
@property | @property | ||||
def ADDITIONAL_CONFIG(self): # noqa: N802 | def ADDITIONAL_CONFIG(self): # noqa: N802 | ||||
return { | return { | ||||
'lister_db_url': | |||||
('str', 'postgresql:///lister-%s' % self.LISTER_NAME), | |||||
'credentials': | 'credentials': | ||||
('list[dict]', []), | ('list[dict]', []), | ||||
'cache_responses': | 'cache_responses': | ||||
('bool', False), | ('bool', False), | ||||
'cache_dir': | 'cache_dir': | ||||
('str', '~/.cache/swh/lister/%s' % self.LISTER_NAME), | ('str', '~/.cache/swh/lister/%s' % self.LISTER_NAME), | ||||
} | } | ||||
Show All 13 Lines | def __init__(self, override_config=None): | ||||
config.prepare_folders(self.config, 'cache_dir') | config.prepare_folders(self.config, 'cache_dir') | ||||
if override_config: | if override_config: | ||||
self.config.update(override_config) | self.config.update(override_config) | ||||
logger.debug('%s CONFIG=%s' % (self, self.config)) | logger.debug('%s CONFIG=%s' % (self, self.config)) | ||||
self.storage = get_storage(**self.config['storage']) | self.storage = get_storage(**self.config['storage']) | ||||
self.scheduler = get_scheduler(**self.config['scheduler']) | self.scheduler = get_scheduler(**self.config['scheduler']) | ||||
self.db_engine = create_engine(self.config['lister_db_url']) | self.db_engine = create_engine(self.config['lister']['args']['db']) | ||||
self.mk_session = sessionmaker(bind=self.db_engine) | self.mk_session = sessionmaker(bind=self.db_engine) | ||||
self.db_session = self.mk_session() | self.db_session = self.mk_session() | ||||
def reset_backoff(self): | def reset_backoff(self): | ||||
"""Reset exponential backoff timeout to initial level.""" | """Reset exponential backoff timeout to initial level.""" | ||||
self.backoff = self.INITIAL_BACKOFF | self.backoff = self.INITIAL_BACKOFF | ||||
def back_off(self): | def back_off(self): | ||||
▲ Show 20 Lines • Show All 272 Lines • Show Last 20 Lines |