pub struct Dispatcher<U, Err>{ /* private fields */ }Expand description
Future that dispatches decoded transport frames to a service.
The service receives DispatchItem values and returns
Option<U::Item>, where Some(item) is encoded and written to the
transport and None produces no response.
Multiple service calls may be in flight concurrently. When the
transport applies write backpressure, the dispatcher pauses normal
reads and emits Control::WBackPressureEnabled. It emits
Control::WBackPressureDisabled before resuming normal processing.
Before shutdown, transport and codec failures are delivered to the
service as DispatchItem::Stop. The future resolves to Err only
when the service itself fails. Graceful and protocol stops drain service
calls before shutdown; transport failures abandon pending calls after
delivering the stop notification so they cannot block teardown.
Implementations§
Source§impl<U, Err> Dispatcher<U, Err>
impl<U, Err> Dispatcher<U, Err>
Sourcepub fn new<Io>(
io: Io,
codec: U,
service: Pipeline<DispatchItem<U>, Option<<U as Encoder>::Item>, Err>,
) -> Dispatcher<U, Err> ⓘ
pub fn new<Io>( io: Io, codec: U, service: Pipeline<DispatchItem<U>, Option<<U as Encoder>::Item>, Err>, ) -> Dispatcher<U, Err> ⓘ
Creates a dispatcher for an I/O transport, codec, and service pipeline.
Keep-alive and frame-read timeout behavior is taken from the transport’s
ntex_io::IoConfig.
Sourcepub fn max_inflight(self, max: u32) -> Dispatcher<U, Err> ⓘ
pub fn max_inflight(self, max: u32) -> Dispatcher<U, Err> ⓘ
Sets the maximum number of concurrent service calls.
The dispatcher stops reading frames while max calls are in flight
and resumes once a call completes. By default the number of calls
is not limited.
§Panics
Panics if max is zero.