forked from TrueCloudLab/frostfs-testlib
21 lines
780 B
Python
21 lines
780 B
Python
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,
|
|
}
|