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