mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-03 01:35:22 +03:00
Setup communication layer
This commit is contained in:
parent
5846981da6
commit
407ed24d36
33
frigate/communication/dispatcher.py
Normal file
33
frigate/communication/dispatcher.py
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
"""Handle communication between frigate and other applications."""
|
||||||
|
|
||||||
|
from abc import ABC, abstractmethod
|
||||||
|
|
||||||
|
from frigate.config import FrigateConfig
|
||||||
|
from frigate.types import CameraMetricsTypes
|
||||||
|
|
||||||
|
|
||||||
|
class Communicator(ABC):
|
||||||
|
"""pub/sub model via specific protocol."""
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def publish(topic: str, payload, retain: bool = False):
|
||||||
|
"""Send data via specific protocol."""
|
||||||
|
pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def subscribe(receiver):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class Dispatcher:
|
||||||
|
"""Handle communication between frigate and communicators."""
|
||||||
|
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
config: FrigateConfig,
|
||||||
|
camera_metrics: dict[str, CameraMetricsTypes],
|
||||||
|
communicators: list[Communicator],
|
||||||
|
) -> None:
|
||||||
|
self.config = config
|
||||||
|
self.camera_metrics = camera_metrics
|
||||||
|
self.comms = communicators
|
||||||
Loading…
Reference in New Issue
Block a user