blackbull.mqtt.tap¶
blackbull.mqtt.tap
¶
Best-effort application taps independent of broker routing.
Actor mode drops newest on bounded-inbox overflow; inline mode backpressures only the publishing connection. Both share matching. A {name} topic segment captures one level and supplies a keyword argument.
Message
dataclass
¶
Immutable published-message view for on_message taps.
Tap
dataclass
¶
Compiled on_message filter with named captures.
display_filter
property
¶
The topic filter as originally written, with {name} captures
restored (match_filter rewrites each to + for matching).
'sensors/{room}/temperature' round-trips back to itself; a plain
'sensors/+/temperature' stays as 'sensors/+/temperature'.
bind(topic)
¶
Return captured {name: value} if topic matches, else None.
TapActor
¶
compile_taps(handlers)
¶
Normalise a handler list to Tap objects.
Accepts already-compiled Tap objects or (topic, callback) pairs, so
direct callers (tests, benchmarks) can keep the lightweight tuple form.
run_taps(taps, message, *, raise_exceptions=False)
async
¶
Invoke every tap whose filter matches message (sequential, isolated).
Captured {name} segments are passed as keyword arguments; a handler
without captures is simply called callback(message).
A handler exception is logged and isolated by default — taps are
best-effort observers, and one raising handler must not stop the others
(nor the broker). raise_exceptions=True propagates the first one
instead, so a failing tap fails a test rather than a log line.