Skip to content

blackbull.mqtt.broker

blackbull.mqtt.broker

Single-owner MQTT routing and session state.

Per-connection actors send commands through the serial broker inbox. Keep admission, retirement and session mutations on that FIFO boundary.

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 actor split.

close()

Release the timer and wake producers whose consumer has stopped.

ClientAuth dataclass

Bases: Message

An AUTH packet; it does not grant or renew connection admission.

ClientPing dataclass

Bases: Message

A PINGREQ whose reply must follow CONNECT admission.

ClientProtocolError dataclass

Bases: Message

A terminal wire or client-direction error, ordered after admission.

ClientPuback dataclass

Bases: Message

The client's PUBACK; the outbound QoS 1 message for this packet id is delivered and its slot is free.

ClientPubcomp dataclass

Bases: Message

The client's PUBCOMP; the outbound QoS 2 exchange for this packet id is finished and its slot is free.

ClientPublish dataclass

Bases: Message

A PUBLISH arrived; route it to matching subscribers.

admitted is an optional future the broker resolves with whether the sender still held a session when this packet reached the front of the inbox. A reader may pipeline PUBLISH ahead of CONNACK, and only the broker's own FIFO knows whether a rejection or a takeover overtook it, so a caller that must act after the packet is accepted awaits this rather than assuming the send succeeded.

ClientPubrec dataclass

Bases: Message

The client's PUBREC for an outbound QoS 2 message.

A reason_code below 0x80 is answered with PUBREL and the flow waits for PUBCOMP (§4.3.3-4); an error code (§2.4) ends the exchange — no PUBREL, and the packet identifier and window slot are released (§2.2.1, §4.9). A successful PUBREC keeps its window slot until PUBCOMP.

ClientPubrel dataclass

Bases: Message

The client's PUBREL for an inbound QoS 2 message; the broker releases the held message and answers with PUBCOMP.

ClientSubscribe dataclass

Bases: Message

A SUBSCRIBE arrived; record its filters and reply with SUBACK.

ClientUnsubscribe dataclass

Bases: Message

An UNSUBSCRIBE arrived; drop its filters and reply with UNSUBACK.

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).

session_expiry_interval carries the property of the same name from the client's DISCONNECT (§3.14.2.2.2), which may shorten — but never lengthen — what its CONNECT declared. None means the packet did not carry one, or the connection ended without a DISCONNECT at all.

Send dataclass

Bases: Message

Offer packet to the connection's bounded, sole-writer handoff.