from typing import Dict, Optional, List from .method import Method class ContainerMatch: __slots__ = ('by_name', ) by_name: str def __init__(self, by_name: str) -> None: self.by_name = by_name def __repr__(self) -> str: return f'ContainerMatch({repr(self.by_name)})' class Service: __slots__ = ('name', 'container_match', 'methods', ) name: str container_match: ContainerMatch methods: Dict[str, Method] def __init__(self, name: str, container_match: ContainerMatch, methods: List[Method]) -> None: self.name = name self.container_match = container_match self.methods = { x.name: x for x in methods } def __repr__(self) -> str: return f'Service({repr(self.name)}, {repr(self.container_match)}, {repr(list(self.methods.values()))})' class ServiceDiscoveryInterface: def find_service(self, name: str) -> Optional[Service]: raise NotImplementedError