pub struct Dispatcher { /* private fields */ }Expand description
One endpoint’s incoming requests, routed to any number of concurrent calls.
Owns the endpoint’s Receiver<Incoming>, which is the whole reason it can promise anything:
there is exactly one of those, so anything else reading it would be reading requests this
cannot then route.
Implementations§
Source§impl Dispatcher
impl Dispatcher
Sourcepub fn new(endpoint: Handle, incoming: Receiver<Incoming>) -> Self
pub fn new(endpoint: Handle, incoming: Receiver<Incoming>) -> Self
Take over an endpoint’s incoming requests, with the default per-call queue depth.
Sourcepub fn with_queue(
endpoint: Handle,
incoming: Receiver<Incoming>,
queue: usize,
) -> Self
pub fn with_queue( endpoint: Handle, incoming: Receiver<Incoming>, queue: usize, ) -> Self
The same, with a per-call queue depth of your own.
A depth of zero is raised to one: an unbuffered channel would shed every request that
arrived while the call was between recv calls, which is most of them.
Sourcepub fn with_identity(self, identity: InboundIdentityPolicy) -> Self
pub fn with_identity(self, identity: InboundIdentityPolicy) -> Self
Verify new inbound INVITEs before they become answerable application invitations.
A verification failure is sent on the INVITE transaction with its RFC 8224 status and the request is not surfaced. With no selected policy, dispatch remains wire-compatible and performs no credential acquisition or time read.
Sourcepub fn with_notifier(self, notifier: Notifier) -> Self
pub fn with_notifier(self, notifier: Notifier) -> Self
Serve inbound RFC 6665 SUBSCRIBE requests through this bounded notifier.
Sourcepub fn with_event_subscriptions(self, subscriptions: EventSubscriptions) -> Self
pub fn with_event_subscriptions(self, subscriptions: EventSubscriptions) -> Self
Route inbound NOTIFY requests to a bounded outbound event-subscription client.
Sourcepub fn with_publications(self, publications: Publications) -> Self
pub fn with_publications(self, publications: Publications) -> Self
Serve inbound PUBLISH and attach outbound publication transactions to this endpoint.
Sourcepub fn calls(&self) -> Calls
pub fn calls(&self) -> Calls
A handle for registering calls this dispatcher did not itself surface.
Sourcepub fn register(&self, dialog: &Dialog) -> Receiver<Incoming>
pub fn register(&self, dialog: &Dialog) -> Receiver<Incoming>
Route this dialog’s requests to the returned inbox — Calls::register, for an
application that holds the dispatcher directly.
Sourcepub fn counts(&self) -> DispatchCounts
pub fn counts(&self) -> DispatchCounts
What has been refused, shed or left unplaced.
Sourcepub fn begin_drain(&mut self)
pub fn begin_drain(&mut self)
Atomically close new-dialog admission for this dispatcher and its transport endpoint.
Existing routes and transactions remain live. Calling this more than once is harmless.
Sourcepub const fn is_draining(&self) -> bool
pub const fn is_draining(&self) -> bool
Whether new-dialog admission has been closed.
Sourcepub async fn drain_progress(&self) -> Result<DrainProgress>
pub async fn drain_progress(&self) -> Result<DrainProgress>
Observe the two completion dimensions used by Self::drain.
Sourcepub async fn drain(&mut self, within: Duration) -> Result<DrainReport>
pub async fn drain(&mut self, within: Duration) -> Result<DrainReport>
Close admission, drive existing dialogs and transactions, and stop the endpoint.
Completion is event-driven: route receiver closure and the endpoint’s transaction-terminal
barrier. within only bounds failure. At expiry every remaining route is closed, the live
counts are logged and returned, and the ordinary endpoint shutdown path cancels and joins
transport-owned tasks.
Sourcepub async fn next(&mut self) -> Option<Dispatched>
pub async fn next(&mut self) -> Option<Dispatched>
The next thing the dispatcher cannot place itself.
Routes everything else on the way, so this must be called in a loop for a dispatcher to
do its job at all — the ACKs and BYEs of every call it has already handed out move only
while it is being polled. None once the endpoint has shut down.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Dispatcher
impl !RefUnwindSafe for Dispatcher
impl Send for Dispatcher
impl Sync for Dispatcher
impl Unpin for Dispatcher
impl UnsafeUnpin for Dispatcher
impl !UnwindSafe for Dispatcher
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more