Files
frigate/frigate/comms/base_communicator.py
T

39 lines
1.1 KiB
Python
Raw Normal View History

2025-02-10 20:47:15 -06:00
from abc import ABC, abstractmethod
2026-07-06 09:28:02 -08:00
from collections.abc import Callable
2026-08-17 11:58:18 -05:00
from typing import TYPE_CHECKING, Any
if TYPE_CHECKING:
from frigate.comms.dispatcher import Dispatcher
2025-02-10 20:47:15 -06:00
class Communicator(ABC):
"""pub/sub model via specific protocol."""
2026-08-17 11:58:18 -05:00
def attach_dispatcher(self, dispatcher: "Dispatcher") -> None:
"""Receive the owning dispatcher.
Transports that need more than the receiver callback (the command topic
surface, the snapshot API) take it here rather than reaching through the
bound receiver.
"""
return None
def start(self) -> None:
"""Start background I/O after receiver wiring is complete."""
return None
2025-02-10 20:47:15 -06:00
@abstractmethod
def publish(self, topic: str, payload: Any, retain: bool = False) -> None:
"""Send data via specific protocol."""
pass
@abstractmethod
def subscribe(self, receiver: Callable) -> None:
"""Pass receiver so communicators can pass commands."""
pass
@abstractmethod
def stop(self) -> None:
"""Stop the communicator."""
pass