monitor.broadcast

Broadcaster — fan-out of monitor payloads to SSE subscriber queues.

One asyncio.Queue per connected dashboard tab. publish() uses put_nowait() — safe because collection and the SSE route handlers all run on the same event loop.

class otto.monitor.broadcast.Broadcaster

Bases: object

Holds SSE subscriber queues and pushes JSON-safe payloads to all of them.

subscribe() Queue[dict[str, Any]]

Register a new subscriber and return its queue.

unsubscribe(q: Queue[dict[str, Any]]) None

Remove q so it receives no further pushes (unknown queues are a no-op).

publish(payload: dict[str, Any]) None

Push a JSON-safe dict to every subscriber queue.