pub struct BatchPolicy { /* private fields */ }Expand description
Trigger configuration for a batching stage.
All configured triggers OR together: the batch is flushed as soon
as any one of them is satisfied. At least one of max_items,
max_bytes, or max_age must be set for the builder to accept
the policy.
§Example
use pipe_io::BatchPolicy;
let p = BatchPolicy::new().max_items(1_000);
assert_eq!(p.items_limit(), Some(1_000));Implementations§
Source§impl BatchPolicy
impl BatchPolicy
Sourcepub const fn new() -> Self
pub const fn new() -> Self
Construct a new empty policy. At least one trigger must be set before the policy is used by the builder.
Sourcepub const fn max_bytes(self, n: usize) -> Self
pub const fn max_bytes(self, n: usize) -> Self
Set the maximum byte size per batch. Requires the item type to
implement ByteSize.
Sourcepub const fn max_age(self, age: Duration) -> Self
Available on crate feature std only.
pub const fn max_age(self, age: Duration) -> Self
std only.Set the maximum age of a batch (time between first push and
flush). Requires the std feature.
Sourcepub const fn items_limit(&self) -> Option<usize>
pub const fn items_limit(&self) -> Option<usize>
Current items trigger.
Sourcepub const fn bytes_limit(&self) -> Option<usize>
pub const fn bytes_limit(&self) -> Option<usize>
Current byte trigger.
Sourcepub const fn age_limit(&self) -> Option<Duration>
Available on crate feature std only.
pub const fn age_limit(&self) -> Option<Duration>
std only.Current age trigger.
Sourcepub const fn has_trigger(&self) -> bool
pub const fn has_trigger(&self) -> bool
True if at least one trigger is configured.
Trait Implementations§
Source§impl Clone for BatchPolicy
impl Clone for BatchPolicy
Source§fn clone(&self) -> BatchPolicy
fn clone(&self) -> BatchPolicy
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for BatchPolicy
impl Debug for BatchPolicy
Source§impl Default for BatchPolicy
impl Default for BatchPolicy
Source§fn default() -> BatchPolicy
fn default() -> BatchPolicy
Returns the “default value” for a type. Read more
impl Copy for BatchPolicy
Auto Trait Implementations§
impl Freeze for BatchPolicy
impl RefUnwindSafe for BatchPolicy
impl Send for BatchPolicy
impl Sync for BatchPolicy
impl Unpin for BatchPolicy
impl UnsafeUnpin for BatchPolicy
impl UnwindSafe for BatchPolicy
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