pub enum BatchMode {
Fixed(NonZeroUsize),
Adaptive(NonZeroUsize, Duration),
Timed {
max_size: NonZeroUsize,
interval: Duration,
},
Single,
}Expand description
Which policy to use for batching the messages before sending them.
Avoid constructing directly this enumeration, please use BatchMode::fixed() and
BatchMode::adaptive() constructors.
The default batch mode is Adaptive(1024, 50ms), meaning that a batch is flushed either when
it has at least 1024 messages, or no message has been received in the last 50ms.
Variants§
Fixed(NonZeroUsize)
A batch is flushed only when the specified number of messages is present.
Adaptive(NonZeroUsize, Duration)
A batch is flushed only when the specified number of messages is present or a timeout expires. NOTE: The timer is checked only when a new message arrives, for background timers with a small execution overhead use BatchMode::Timed
Timed
A batch is flushed only when the specified number of messages is present or a timeout expires. The timer is checked in the background. Using background timers may incud in a very small perfomance overhead when compared to Fixed or Adaptive batching
Single
Send a size 1 batch for each element
Implementations§
Source§impl BatchMode
impl BatchMode
Sourcepub fn fixed(size: usize) -> BatchMode
pub fn fixed(size: usize) -> BatchMode
Construct a new BatchMode::Fixed with the given positive batch size.
Sourcepub fn adaptive(size: usize, max_delay: Duration) -> BatchMode
pub fn adaptive(size: usize, max_delay: Duration) -> BatchMode
Construct a new BatchMode::Adaptive with the given positive batch size and maximum delay.
Sourcepub fn timed(size: usize, interval: Duration) -> BatchMode
pub fn timed(size: usize, interval: Duration) -> BatchMode
Construct a new BatchMode::Adaptive with the given positive batch size and maximum delay.
pub fn max_delay(&self) -> Option<Duration>
Trait Implementations§
impl Copy for BatchMode
impl Eq for BatchMode
impl StructuralPartialEq for BatchMode
Auto Trait Implementations§
impl Freeze for BatchMode
impl RefUnwindSafe for BatchMode
impl Send for BatchMode
impl Sync for BatchMode
impl Unpin for BatchMode
impl UnwindSafe for BatchMode
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> CloneDebuggableStorage for Twhere
T: DebuggableStorage + Clone,
impl<T> CloneDebuggableStorage for Twhere
T: DebuggableStorage + Clone,
fn clone_storage(&self) -> Box<dyn CloneDebuggableStorage>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> CloneableStorage for T
impl<T> CloneableStorage for T
fn clone_storage(&self) -> Box<dyn CloneableStorage>
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.