Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/__init__.py
# Copyright (C) 2015-2020 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 | |||||
Storage = storage.Storage | |||||
class HashCollision(Exception): | class HashCollision(Exception): | ||||
pass | pass | ||||
STORAGE_IMPLEMENTATION = { | STORAGE_IMPLEMENTATION = { | ||||
'pipeline', 'local', 'remote', 'memory', 'filter', 'buffer', 'retry', | 'pipeline', 'local', 'remote', 'memory', 'filter', 'buffer', 'retry', | ||||
'cassandra', | |||||
} | } | ||||
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: | ||||
Show All 21 Lines | def get_storage(cls, **kwargs): | ||||
if cls == 'pipeline': | if cls == 'pipeline': | ||||
return get_storage_pipeline(**kwargs) | return get_storage_pipeline(**kwargs) | ||||
if cls == 'remote': | if cls == 'remote': | ||||
from .api.client import RemoteStorage as Storage | from .api.client import RemoteStorage as Storage | ||||
elif cls == 'local': | elif cls == 'local': | ||||
from .storage import Storage | from .storage import Storage | ||||
elif cls == 'cassandra': | |||||
from .cassandra import CassandraStorage as 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': | elif cls == 'retry': | ||||
from .retry import RetryingProxyStorage as Storage | from .retry import RetryingProxyStorage as Storage | ||||
Show All 34 Lines |