pub struct BufferedDispatcher<'a, T> { /* private fields */ }
Expand description
A buffered dispatcher.
BufferedDispatcher
provides an efficient and ergonomic interface to Dispatcher
that allows for writing events
one-by-one into batches, which are then dispatched to the configured output as needed. This allows callers to focus
on the logic around what items to send, without needing to worry about the details of event buffer sizing or
flushing.
Implementations§
Source§impl<T> BufferedDispatcher<'_, T>where
T: DispatchBuffer,
impl<T> BufferedDispatcher<'_, T>where
T: DispatchBuffer,
Sourcepub async fn push(&mut self, item: T::Item) -> Result<(), GenericError>
pub async fn push(&mut self, item: T::Item) -> Result<(), GenericError>
Pushes an item into the buffered dispatcher.
§Errors
If there is an error flushing items to the output, or if there is an error acquiring a new buffer, an error is returned.
Sourcepub async fn send_all<I>(self, items: I) -> Result<usize, GenericError>where
I: IntoIterator<Item = T::Item>,
pub async fn send_all<I>(self, items: I) -> Result<usize, GenericError>where
I: IntoIterator<Item = T::Item>,
Consumes this buffered dispatcher and sends/flushes all input items to the underlying output.
If flushing is successful, Ok(flushed)
is returned, where flushed
is the total number of items that
have been flushed through this buffered dispatcher.
§Errors
If there is an error sending items to the output, an error is returned.
Sourcepub async fn flush(self) -> Result<usize, GenericError>
pub async fn flush(self) -> Result<usize, GenericError>
Consumes this buffered dispatcher, flushing any buffered items to the underlying output.
If flushing is successful, Ok(flushed)
is returned, where flushed
is the total number of items that have
been flushed through this buffered dispatcher.
§Errors
If there is an error sending items to the output, an error is returned.
Auto Trait Implementations§
impl<'a, T> Freeze for BufferedDispatcher<'a, T>where
T: Freeze,
impl<'a, T> !RefUnwindSafe for BufferedDispatcher<'a, T>
impl<'a, T> Send for BufferedDispatcher<'a, T>where
T: Send,
impl<'a, T> Sync for BufferedDispatcher<'a, T>
impl<'a, T> Unpin for BufferedDispatcher<'a, T>where
T: Unpin,
impl<'a, T> !UnwindSafe for BufferedDispatcher<'a, 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