forked from TrueCloudLab/frostfs-testlib
Move shared code to testlib
Signed-off-by: Andrey Berezin <a.berezin@yadro.com>
This commit is contained in:
parent
d97a02d1d3
commit
997e768e92
69 changed files with 9213 additions and 64 deletions
21
src/frostfs_testlib/storage/service_registry.py
Normal file
21
src/frostfs_testlib/storage/service_registry.py
Normal file
|
@ -0,0 +1,21 @@
|
|||
from frostfs_testlib.storage.dataclasses.node_base import NodeBase, NodeClassDict, ServiceClass
|
||||
|
||||
|
||||
class ServiceRegistry:
|
||||
_class_mapping: dict[str, NodeClassDict] = {}
|
||||
|
||||
def get_entry(self, service_type: type[ServiceClass]) -> NodeClassDict:
|
||||
key = service_type.__name__
|
||||
|
||||
if key not in self._class_mapping:
|
||||
raise RuntimeError(
|
||||
f"Unregistered service type requested: {key}. At this moment registered services are: {self._class_mapping.keys()}"
|
||||
)
|
||||
|
||||
return self._class_mapping[key]
|
||||
|
||||
def register_service(self, service_name: str, service_class: type[NodeBase]):
|
||||
self._class_mapping[service_class.__name__] = {
|
||||
"cls": service_class,
|
||||
"hosting_service_name": service_name,
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue