pub trait ConnectionNotifier:
Debug
+ Send
+ Sync {
// Required methods
fn on_worker_registered(
&self,
pid: u64,
registration: &WorkerRegistration,
) -> Result<(), ServerError>;
fn on_worker_unregistered(&self, pid: u64);
// Provided methods
fn on_channel_publish(
&self,
pid: u64,
channel: &str,
payload: &[u8],
) -> bool { ... }
fn on_pass_attached(&self, pid: u64, principal: &PassPrincipal) { ... }
fn on_pass_detached(&self, pid: u64, principal: &PassPrincipal) { ... }
}Expand description
Application hook invoked when a worker registers or unregisters on a connection.
Implementations associate the connection’s beamr process id (pid) with the
worker’s declared WorkerRegistration so the application can route work to
it, and release that association on disconnect. The hook is synchronous: a
registration is acknowledged to the worker only after
on_worker_registered returns, so a rejecting
application surfaces a Rejected ack instead of leaving the worker silently
connected but never dispatched-to.
Required Methods§
Sourcefn on_worker_registered(
&self,
pid: u64,
registration: &WorkerRegistration,
) -> Result<(), ServerError>
fn on_worker_registered( &self, pid: u64, registration: &WorkerRegistration, ) -> Result<(), ServerError>
Called when a worker registers on the connection identified by pid.
Returning Ok(()) accepts the registration (the worker receives an
Accepted ack). Returning ServerError rejects it (the worker receives
a Rejected ack carrying the error text), so a failed association never
leaves the worker believing it is registered.
§Errors
Returns ServerError when the application declines the registration.
Sourcefn on_worker_unregistered(&self, pid: u64)
fn on_worker_unregistered(&self, pid: u64)
Called when the connection identified by pid — which had a stored
registration — closes, so the application can release the association.
Deregistration is best-effort and infallible from the connection’s perspective: it runs on the close path where there is no peer to report an error to.
Provided Methods§
Sourcefn on_channel_publish(&self, pid: u64, channel: &str, payload: &[u8]) -> bool
fn on_channel_publish(&self, pid: u64, channel: &str, payload: &[u8]) -> bool
Called when the connection identified by pid publishes to channel,
carrying the opaque envelope payload, BEFORE the normal channel fan-out.
Returns true when the application CONSUMED the publish out-of-band (an
observability-drain tap): the connection process then does NOT route it to the
channel-fan-out cluster and answers with no wire response, so a tapped channel
need not be a declared fan-out channel. Returns false (the default) to let
the publish flow through the normal channel machinery unchanged.
This is the observability-drain hook: a worker publishing an agent transcript event to the reserved observability channel is consumed here — the hosting application (aion) persists and live-fans-out the event without a second connection. It is fire-and-forget: a publish is a one-way notification, so there is no reply and a failed persist is the application’s concern to log.
The default returns false, so liminal still runs standalone: with no
notifier, or a notifier that does not recognise the channel, every publish
routes to the normal fan-out exactly as before.
Sourcefn on_pass_attached(&self, pid: u64, principal: &PassPrincipal)
fn on_pass_attached(&self, pid: u64, principal: &PassPrincipal)
Called exactly once when a Connect carrying a registry pass has
SUCCEEDED on the connection identified by pid — after the pass
verified, version negotiation passed, and the handshake was admitted —
carrying the principal the pass stamped: participant, public key, live
prefix, conversation scope, may_enroll. pid is the connection’s own
id, the same one every other hook on this trait is keyed by, so the
matching on_pass_detached can be paired.
A Connect that presents a pass and is refused (or a bearer connection,
which stamps no principal) never reaches this hook. The default does
nothing, so existing implementors compile unchanged and liminal still
runs standalone.
Sourcefn on_pass_detached(&self, pid: u64, principal: &PassPrincipal)
fn on_pass_detached(&self, pid: u64, principal: &PassPrincipal)
Called exactly once when a connection that announced
on_pass_attached closes — for any reason: a
clean Disconnect, the peer ending the transport, a transport error, a
process crash, or supervisor shutdown — carrying the same pid and the
principal the attach carried. Best-effort and infallible like
on_worker_unregistered: it runs on the
close path where there is no peer to report to. The default does
nothing.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".