Changeset View
Changeset View
Standalone View
Standalone View
swh/provenance/__init__.py
Show First 20 Lines • Show All 86 Lines • ▼ Show 20 Lines | if cls in ["local", "postgresql"]: | ||||
) | ) | ||||
elif cls == "mongodb": | elif cls == "mongodb": | ||||
from .mongo.backend import ProvenanceStorageMongoDb | from .mongo.backend import ProvenanceStorageMongoDb | ||||
engine = kwargs.get("engine", "pymongo") | engine = kwargs.get("engine", "pymongo") | ||||
return ProvenanceStorageMongoDb(engine=engine, **kwargs["db"]) | return ProvenanceStorageMongoDb(engine=engine, **kwargs["db"]) | ||||
elif cls == "rabbitmq": | |||||
from .api.client import ProvenanceStorageRabbitMQClient | |||||
rmq_storage = ProvenanceStorageRabbitMQClient(**kwargs) | |||||
if TYPE_CHECKING: | |||||
assert isinstance(rmq_storage, ProvenanceStorageInterface) | |||||
return rmq_storage | |||||
elif cls in ["remote", "rpcapi"]: | elif cls in ["remote", "rpcapi"]: | ||||
from .api.client import ProvenanceStorageRPCClient | from .api.client import ProvenanceStorageRPCClient | ||||
if cls == "remote": | if cls == "remote": | ||||
warnings.warn( | warnings.warn( | ||||
'"remote" class is deprecated for provenance storage, please ' | '"remote" class is deprecated for provenance storage, please ' | ||||
'use "rpcapi" class instead.', | 'use "rpcapi" class instead.', | ||||
DeprecationWarning, | DeprecationWarning, | ||||
) | ) | ||||
rpc_storage = ProvenanceStorageRPCClient(**kwargs) | rpc_storage = ProvenanceStorageRPCClient(**kwargs) | ||||
if TYPE_CHECKING: | if TYPE_CHECKING: | ||||
assert isinstance(rpc_storage, ProvenanceStorageInterface) | assert isinstance(rpc_storage, ProvenanceStorageInterface) | ||||
return rpc_storage | return rpc_storage | ||||
raise ValueError | raise ValueError |