Struct batch_aint_one::Batcher
source · pub struct Batcher<K, I, O = (), E = String> { /* private fields */ }Expand description
Groups items to be processed in batches.
Takes inputs (I) grouped by a key (K) and processes multiple together in a batch. An output
(O) is produced for each input.
Cheap to clone.
Implementations§
source§impl<K, I, O, E> Batcher<K, I, O, E>
impl<K, I, O, E> Batcher<K, I, O, E>
sourcepub fn new<F>(processor: F, batching_strategy: BatchingStrategy) -> Self
pub fn new<F>(processor: F, batching_strategy: BatchingStrategy) -> Self
Create a new batcher.
sourcepub async fn add(&self, key: K, input: I) -> Result<O, BatchError<E>>
pub async fn add(&self, key: K, input: I) -> Result<O, BatchError<E>>
Add an item to the batch and await the result.
Trait Implementations§
Auto Trait Implementations§
impl<K, I, O = (), E = String> !RefUnwindSafe for Batcher<K, I, O, E>
impl<K, I, O, E> Send for Batcher<K, I, O, E>
impl<K, I, O, E> Sync for Batcher<K, I, O, E>
impl<K, I, O, E> Unpin for Batcher<K, I, O, E>
impl<K, I, O = (), E = String> !UnwindSafe for Batcher<K, I, O, E>
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