#[non_exhaustive]pub enum BatchingPolicy {
Immediate,
Size,
Duration(Duration, OnFull),
Balanced {
min_size_hint: usize,
},
}Expand description
A policy controlling when batches get processed.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Immediate
Immediately process the batch if possible.
When concurrency and resources are available, new items will be processed immediately (with a batch size of one).
When resources are not immediately available, then the batch will remain open while acquiring resources to allow more items to be added, up to the maximum batch size.
In this way, we try to prioritise larger batch sizes, while still keeping latency low.
When concurrency is maximised, new items will added to the next batch (up to the maximum batch size). As soon as a batch finishes the next batch will start. When concurrency is limited to 1, it will run batches serially.
Prioritises low latency.
Size
Process the batch when it reaches the maximum size.
Prioritises high batch utilisation.
Duration(Duration, OnFull)
Process the batch a given duration after it was created.
If using OnFull::Process, then process the batch when either the duration elapses or the
batch becomes full, whichever happens first.
Prioritises regularity.
Balanced
Balance between resource efficiency and latency based on system load.
When no batches are processing, the first item processes immediately.
When batches are already processing:
- If batch size <
min_size_hint: Wait for either the batch to reachmin_size_hintor any batch to complete - If batch size >=
min_size_hint: Start acquiring resources and process immediately
The min_size_hint must be <= max_batch_size.
Prioritises efficient resource usage while maintaining reasonable latency.
Trait Implementations§
Source§impl Clone for BatchingPolicy
impl Clone for BatchingPolicy
Source§fn clone(&self) -> BatchingPolicy
fn clone(&self) -> BatchingPolicy
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more