Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/__init__.py
# Copyright (C) 2015-2016 The Software Heritage developers | # Copyright (C) 2015-2020 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
import warnings | import warnings | ||||
from . import storage | from . import storage | ||||
Storage = storage.Storage | Storage = storage.Storage | ||||
class HashCollision(Exception): | class HashCollision(Exception): | ||||
pass | pass | ||||
STORAGE_IMPLEMENTATION = { | STORAGE_IMPLEMENTATION = { | ||||
'pipeline', 'local', 'remote', 'memory', 'filter', 'buffer'} | 'pipeline', 'local', 'remote', 'memory', 'filter', 'buffer', 'retry', | ||||
} | |||||
vlorentz: nitpick: for consistency, it should be a substantive, like "retryer" (which is a neologism, for… | |||||
Done Inline Actionshum, i found this ugly. Plus, we do not really see that consistency (among all storages i mean). ardumont: hum, i found this ugly.
Plus, we do not really see that consistency (among all storages i… | |||||
Done Inline ActionsAlso, see retry as a verb like buffer and filter are, maybe that will help. ardumont: Also, see `retry` as a verb like `buffer` and `filter` are, maybe that will help. | |||||
def get_storage(cls, **kwargs): | def get_storage(cls, **kwargs): | ||||
"""Get a storage object of class `storage_class` with arguments | """Get a storage object of class `storage_class` with arguments | ||||
`storage_args`. | `storage_args`. | ||||
Args: | Args: | ||||
storage (dict): dictionary with keys: | storage (dict): dictionary with keys: | ||||
Show All 26 Lines | def get_storage(cls, **kwargs): | ||||
elif cls == 'local': | elif cls == 'local': | ||||
from .storage import Storage | from .storage import Storage | ||||
elif cls == 'memory': | elif cls == 'memory': | ||||
from .in_memory import Storage | from .in_memory import Storage | ||||
elif cls == 'filter': | elif cls == 'filter': | ||||
from .filter import FilteringProxyStorage as Storage | from .filter import FilteringProxyStorage as Storage | ||||
elif cls == 'buffer': | elif cls == 'buffer': | ||||
from .buffer import BufferingProxyStorage as Storage | from .buffer import BufferingProxyStorage as Storage | ||||
elif cls == 'retry': | |||||
Not Done Inline Actionssame vlorentz: same | |||||
from .retry import RetryingProxyStorage as Storage | |||||
return Storage(**kwargs) | return Storage(**kwargs) | ||||
def get_storage_pipeline(steps): | def get_storage_pipeline(steps): | ||||
"""Recursively get a storage object that may use other storage objects | """Recursively get a storage object that may use other storage objects | ||||
as backends. | as backends. | ||||
Show All 26 Lines |
nitpick: for consistency, it should be a substantive, like "retryer" (which is a neologism, for lack of a better word)