Source code for caspia.gateway.services.base

from abc import ABCMeta, abstractmethod, abstractproperty

from caspia.meadow.client.gateway import ServiceGatewayMixin
from caspia.meadow.services import ServiceMeta

service_classes = set()


[docs]class GatewayServiceMeta(ServiceMeta, ABCMeta): def __new__(mcs, name, bases, attrs): cls = super().__new__(mcs, name, bases, attrs) service_classes.add(cls) return cls
[docs]class GatewayService(ServiceGatewayMixin, metaclass=GatewayServiceMeta): type = None def __init__(self, config, network, storage): self.config = config super().__init__(config['name']) self.network = network self.storage = storage
[docs] @abstractmethod def configure(self): raise NotImplementedError
@abstractproperty @property def dependant_components(self): pass
[docs] async def on_component_event(self, component, event): pass
[docs] def get_node(self): return self.network.get_node(self.config['node'])