Skip to main content

ConnectionNotifier

Trait ConnectionNotifier 

Source
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);
}
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§

Source

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.

Source

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.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§