blackbull.event_aggregator¶
blackbull.event_aggregator
¶
EventAggregator
¶
Translates Level A Actor messages into Level B EventDispatcher calls.
This class is not an Actor — it has no inbox and no lifecycle of its own. It is instantiated once per application and passed by reference to each Actor at construction time.
Each method corresponds to one Level B event defined in ActorDesign.md. Methods are called by Actors; they must always be called from the event loop thread.
Note
Do not export this class from blackbull/__init__.py.
It is a framework-internal component.
has_request_completed_listeners()
¶
Return True if any request_completed handler is registered.
Read on the request hot path to decide whether the per-request
AccessLogRecord (whose wire fields this event reports) must be built,
and whether the disconnect-detecting receive wrapper (whose
mark_disconnected this event reads to suppress itself on a dropped
request) is observed.
has_request_disconnected_listeners()
¶
Return True if any request_disconnected handler is registered.
Read on the request hot path to decide whether the disconnect-detecting receive wrapper needs to be built at all.
has_websocket_message_listeners()
¶
Return True if any websocket_message handler is registered.
The WebSocket receive path calls this per frame to skip the
Event + detail-dict allocation and the emit indirection when
nothing is listening (the common case on a throughput workload).
Cached against the dispatcher's registration generation, so the
lookup runs only when listeners change.
on_app_shutdown()
async
¶
Fire Level B app_shutdown.
on_app_startup()
async
¶
Fire Level B app_startup.
on_connection_accepted(peername, protocol='http')
async
¶
Fire Level B connection_accepted.
protocol is 'http' for the shared HTTP listener (the h1/h2 split is
not yet known at accept time) and the registered protocol name (e.g.
'echo') for a port-bound non-ASGI connection.
on_connection_closed(peername, protocol, duration_ms)
async
¶
Fire Level B connection_closed.
on_error(conn, exception)
async
¶
Fire Level B error (conn is a Connection, or a scope dict on
the compat lane).
on_message_received(protocol, message_type, payload_size)
async
¶
Fire Level B message_received (application-level message in).
on_message_sent(protocol, message_type, payload_size)
async
¶
Fire Level B message_sent (application-level message out).
on_request_disconnected(conn)
async
¶
Fire Level B request_disconnected.
conn is the native :class:~blackbull.connection.Connection on the
self-hosted path, or an ASGI scope dict only on the BB_FORCE_ASGI_SCOPE
/ external compat lane — :func:_request_fields reads either.
on_websocket_connected(conn, subprotocol=None)
async
¶
Fire Level B websocket_connected (conn is a Connection).
on_websocket_disconnected(conn, code=1006)
async
¶
Fire Level B websocket_disconnected (conn is a Connection).
on_websocket_message(conn, message)
async
¶
Fire Level B websocket_message (conn is a Connection).