pub struct Batch<T, Request>where
T: Service<BatchControl<Request>>,{ /* private fields */ }Expand description
Allows batch processing of requests.
See the module documentation for more details.
Implementations§
Source§impl<T, Request> Batch<T, Request>
impl<T, Request> Batch<T, Request>
Sourcepub fn new(service: T, size: usize, time: Duration) -> Self
pub fn new(service: T, size: usize, time: Duration) -> Self
Creates a new Batch wrapping service.
The wrapper is responsible for telling the inner service when to flush a batch of requests.
The default Tokio executor is used to run the given service, which means that this method must be called while on the Tokio runtime.
Sourcepub fn pair(
service: T,
size: usize,
time: Duration,
) -> (Self, Worker<T, Request>)
pub fn pair( service: T, size: usize, time: Duration, ) -> (Self, Worker<T, Request>)
Creates a new Batch wrapping service, but returns the background worker.
This is useful if you do not want to spawn directly onto the tokio
runtime but instead want to use your own executor. This will return the
Batch and the background Worker that you can then spawn.
Trait Implementations§
Source§impl<T, Request> Service<Request> for Batch<T, Request>
impl<T, Request> Service<Request> for Batch<T, Request>
Source§type Response = <T as Service<BatchControl<Request>>>::Response
type Response = <T as Service<BatchControl<Request>>>::Response
Responses given by the service.
Source§type Future = ResponseFuture<<T as Service<BatchControl<Request>>>::Future>
type Future = ResponseFuture<<T as Service<BatchControl<Request>>>::Future>
The future response value.
Auto Trait Implementations§
impl<T, Request> Freeze for Batch<T, Request>
impl<T, Request> !RefUnwindSafe for Batch<T, Request>
impl<T, Request> Send for Batch<T, Request>
impl<T, Request> Sync for Batch<T, Request>
impl<T, Request> Unpin for Batch<T, Request>
impl<T, Request> UnsafeUnpin for Batch<T, Request>
impl<T, Request> !UnwindSafe for Batch<T, Request>
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