ConnectionRouter

Trait ConnectionRouter 

Source
pub trait ConnectionRouter:
    Send
    + Sync
    + 'static {
    // Required method
    fn route(
        &self,
        connection: ConnectionId,
        identity: &ConnectionIdentity,
    ) -> impl Future<Output = RouteDecision> + Send;
}
Expand description

The policy that answers “which shard?”.

Generic rather than dyn on purpose: an async fn in a trait is not dyn-compatible, and boxing every routing decision to work around that would buy nothing. A deployment that genuinely needs runtime polymorphism writes one router that dispatches internally.

Required Methods§

Source

fn route( &self, connection: ConnectionId, identity: &ConnectionIdentity, ) -> impl Future<Output = RouteDecision> + Send

Decide where this connection belongs.

Runs on the connection’s task. It may await, and it may take its time: the cost is borne by the arriving client alone.

The identifier is handed over as well as the claim, because this is the only moment where the two meet. A shard’s [mumble_server_runtime_shard::VoiceEvent] carries a ConnectionId and nothing else - deliberately, since the runtime has no opinion on what a user is - so an application that wants its flavor to know a name records the pair here.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§