pub struct Dispatcher<T>where
T: Dispatchable,{ /* private fields */ }
Expand description
Dispatches items from one component to another.
Dispatcher
provides an ergonomic interface for sending items to a downstream component. It has support for
multiple outputs (a default output, and additional “named” outputs) and provides telemetry around the number of
dispatched items as well as the latency of sending them.
Implementations§
Source§impl<T> Dispatcher<T>where
T: Dispatchable,
impl<T> Dispatcher<T>where
T: Dispatchable,
Sourcepub fn new(context: ComponentContext) -> Self
pub fn new(context: ComponentContext) -> Self
Create a new Dispatcher
for the given component context.
Sourcepub fn add_output(
&mut self,
output_name: OutputName,
) -> Result<(), GenericError>
pub fn add_output( &mut self, output_name: OutputName, ) -> Result<(), GenericError>
Sourcepub fn attach_sender_to_output(
&mut self,
output_name: &OutputName,
sender: Sender<T>,
) -> Result<(), GenericError>
pub fn attach_sender_to_output( &mut self, output_name: &OutputName, sender: Sender<T>, ) -> Result<(), GenericError>
Sourcepub fn is_default_output_connected(&self) -> bool
pub fn is_default_output_connected(&self) -> bool
Returns true
if the default output is connected to downstream components.
Sourcepub fn is_named_output_connected(&self, name: &str) -> bool
pub fn is_named_output_connected(&self, name: &str) -> bool
Returns true
if the named output is connected to downstream components.
Source§impl<T> Dispatcher<T>where
T: DispatchBuffer,
impl<T> Dispatcher<T>where
T: DispatchBuffer,
Sourcepub fn buffered(&self) -> Result<BufferedDispatcher<'_, T>, GenericError>
pub fn buffered(&self) -> Result<BufferedDispatcher<'_, T>, GenericError>
Creates a buffered dispatcher for the default output.
This should generally be used if the items being dispatched are not already collected in a container, or exposed via an iterable type. It allows for efficiently buffering items one-by-one before dispatching them to the underlying output.
§Errors
If the default output has not been configured, an error will be returned.
Sourcepub fn buffered_named<N>(
&self,
output_name: N,
) -> Result<BufferedDispatcher<'_, T>, GenericError>
pub fn buffered_named<N>( &self, output_name: N, ) -> Result<BufferedDispatcher<'_, T>, GenericError>
Creates a buffered dispatcher for the given named output.
This should generally be used if the items being dispatched are not already collected in a container, or exposed via an iterable type. It allows for efficiently buffering items one-by-one before dispatching them to the underlying output.
§Errors
If the given named output has not been configured, an error will be returned.
Auto Trait Implementations§
impl<T> Freeze for Dispatcher<T>
impl<T> !RefUnwindSafe for Dispatcher<T>
impl<T> Send for Dispatcher<T>where
T: Send,
impl<T> Sync for Dispatcher<T>where
T: Send,
impl<T> Unpin for Dispatcher<T>
impl<T> !UnwindSafe for Dispatcher<T>
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request
Source§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> Track for T
impl<T> Track for T
§fn track_allocations(self, token: AllocationGroupToken) -> Tracked<Self>
fn track_allocations(self, token: AllocationGroupToken) -> Tracked<Self>
Tracked
wrapper. Read more§fn in_current_allocation_group(self) -> Tracked<Self>
fn in_current_allocation_group(self) -> Tracked<Self>
Tracked
wrapper. Read more