Skip to content

blackbull.mqtt.broker

blackbull.mqtt.broker

MQTT 5.0 broker — the routing/session state owner (actor model).

:class:BrokerActor is one per app/worker, supervisor/lifespan-owned. It owns all routing state (subscriptions, sessions, retained messages, the live connection registry) and processes its inbox serially, so there are no locks and no shared mutable state. Per-connection actors (see :mod:blackbull.mqtt.connection) send it the Level A messages defined here and receive :class:Send / :class:Close back.

Because the broker outlives every connection actor, a Will (LWT) routes to live subscribers during a peer's teardown with no special-casing.

Attach dataclass

Bases: Message

A client's CONNECT arrived; register it and reply with CONNACK.

BrokerActor

Bases: Actor

Single owner of all MQTT routing state (one per app/worker).

Connection actors send it client events; it sends Send/Close back to them. Serial inbox processing means no locks and no shared mutable state — the design goal of the Sprint 53 refactor.

Close dataclass

Bases: Message

Tell the connection actor to close (e.g. CONNECT rejected).

Detach dataclass

Bases: Message

A client's connection is ending (graceful=False fires its Will).

Send dataclass

Bases: Message

Tell the connection actor to encode + write packet to its socket.