pub struct HybridBatcher<T> { /* private fields */ }Expand description
Hybrid batcher that flushes based on time, count, or size thresholds. Whichever threshold is hit first triggers the flush.
Implementations§
Source§impl<T> HybridBatcher<T>
impl<T> HybridBatcher<T>
pub fn new(config: BatchConfig) -> Self
Sourcepub fn push(&mut self, item: T, size_bytes: usize) -> Option<FlushReason>
pub fn push(&mut self, item: T, size_bytes: usize) -> Option<FlushReason>
Add an item to the batch, returns flush reason if threshold hit
Sourcepub fn should_flush_time(&self) -> bool
pub fn should_flush_time(&self) -> bool
Check if time threshold exceeded
Sourcepub fn take_batch(&mut self) -> Vec<T>
pub fn take_batch(&mut self) -> Vec<T>
Take the current batch for flushing
Source§impl<T: SizedItem> HybridBatcher<T>
Extension methods for SyncItem batching (avoids orphan rules)
impl<T: SizedItem> HybridBatcher<T>
Extension methods for SyncItem batching (avoids orphan rules)
Sourcepub fn add(&mut self, item: T) -> Option<FlushReason>
pub fn add(&mut self, item: T) -> Option<FlushReason>
Add an item using its intrinsic size
Sourcepub fn take_if_ready(&mut self) -> Option<FlushBatch<T>>
pub fn take_if_ready(&mut self) -> Option<FlushBatch<T>>
Take the batch if any threshold is ready
Sourcepub fn force_flush(&mut self) -> Option<FlushBatch<T>>
pub fn force_flush(&mut self) -> Option<FlushBatch<T>>
Force flush regardless of thresholds (for manual flush or shutdown)
Sourcepub fn force_flush_with_reason(
&mut self,
reason: FlushReason,
) -> Option<FlushBatch<T>>
pub fn force_flush_with_reason( &mut self, reason: FlushReason, ) -> Option<FlushBatch<T>>
Force flush with a specific reason
Source§impl<T: BatchableItem> HybridBatcher<T>
Extension methods for batchable items (have ID for contains check)
impl<T: BatchableItem> HybridBatcher<T>
Extension methods for batchable items (have ID for contains check)
Auto Trait Implementations§
impl<T> Freeze for HybridBatcher<T>
impl<T> RefUnwindSafe for HybridBatcher<T>where
T: RefUnwindSafe,
impl<T> Send for HybridBatcher<T>where
T: Send,
impl<T> Sync for HybridBatcher<T>where
T: Sync,
impl<T> Unpin for HybridBatcher<T>where
T: Unpin,
impl<T> UnwindSafe for HybridBatcher<T>where
T: UnwindSafe,
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
Mutably borrows from an owned value. Read more
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> 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>
Converts
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>
Converts
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