pub struct BufferService<St, Req, Res, Err> { /* private fields */ }Expand description
A service that buffers requests while its wrapped service is not ready.
Buffered requests are released in order, one at a time: the next one is
released only after the previous one has completed its call or was
dropped. Shutdown drains the buffer the same way, unless
cancel_on_shutdown is set, and shuts down the
wrapped service afterwards.
The default buffer capacity is 16 requests.
Implementations§
Source§impl<St, Req, Res, Err> BufferService<St, Req, Res, Err>where
St: Clone + 'static,
impl<St, Req, Res, Err> BufferService<St, Req, Res, Err>where
St: Clone + 'static,
Sourcepub fn new(
size: usize,
service: PipelineState<St, Req, Res, Err>,
) -> BufferService<St, Req, Res, Err>
pub fn new( size: usize, service: PipelineState<St, Req, Res, Err>, ) -> BufferService<St, Req, Res, Err>
Creates a buffering service with the specified capacity.
Sourcepub fn cancel_on_shutdown(self) -> BufferService<St, Req, Res, Err>
pub fn cancel_on_shutdown(self) -> BufferService<St, Req, Res, Err>
Cancels pending buffered requests instead of releasing them on shutdown.
Trait Implementations§
Source§impl<St, Req, Res, Err> Debug for BufferService<St, Req, Res, Err>
impl<St, Req, Res, Err> Debug for BufferService<St, Req, Res, Err>
Source§impl<St, Req, Res, Err> Service<St, Req> for BufferService<St, Req, Res, Err>where
St: Clone + 'static,
Req: 'static,
Res: 'static,
Err: 'static,
impl<St, Req, Res, Err> Service<St, Req> for BufferService<St, Req, Res, Err>where
St: Clone + 'static,
Req: 'static,
Res: 'static,
Err: 'static,
Source§type Error = BufferServiceError<Err>
type Error = BufferServiceError<Err>
Error produced while checking readiness or processing a request.
Source§async fn ready(
&self,
ctx: Ctx<'_, BufferService<St, Req, Res, Err>, St>,
) -> Result<(), <BufferService<St, Req, Res, Err> as Service<St, Req>>::Error>
async fn ready( &self, ctx: Ctx<'_, BufferService<St, Req, Res, Err>, St>, ) -> Result<(), <BufferService<St, Req, Res, Err> as Service<St, Req>>::Error>
Waits until the service is ready to process a request. Read more
Source§async fn shutdown(&self, ctx: Ctx<'_, BufferService<St, Req, Res, Err>, St>)
async fn shutdown(&self, ctx: Ctx<'_, BufferService<St, Req, Res, Err>, St>)
Shuts down the service. Read more
Source§async fn call(
&self,
req: Req,
ctx: Ctx<'_, BufferService<St, Req, Res, Err>, St>,
) -> Result<Res, <BufferService<St, Req, Res, Err> as Service<St, Req>>::Error>
async fn call( &self, req: Req, ctx: Ctx<'_, BufferService<St, Req, Res, Err>, St>, ) -> Result<Res, <BufferService<St, Req, Res, Err> as Service<St, Req>>::Error>
Processes a request and asynchronously returns the response. Read more
Source§fn map<F, Res>(self, f: F) -> ServiceChain<Map<F, Self, Res>, St, Req>
fn map<F, Res>(self, f: F) -> ServiceChain<Map<F, Self, Res>, St, Req>
Maps this service’s output to a different type, returning a new service. Read more
Source§fn map_err<F, E>(self, f: F) -> ServiceChain<MapErr<F, Self, E>, St, Req>
fn map_err<F, E>(self, f: F) -> ServiceChain<MapErr<F, Self, E>, St, Req>
Maps this service’s error to a different type, returning a new service. Read more
Auto Trait Implementations§
impl<St, Req, Res, Err> !Freeze for BufferService<St, Req, Res, Err>
impl<St, Req, Res, Err> !RefUnwindSafe for BufferService<St, Req, Res, Err>
impl<St, Req, Res, Err> !Send for BufferService<St, Req, Res, Err>
impl<St, Req, Res, Err> !Sync for BufferService<St, Req, Res, Err>
impl<St, Req, Res, Err> !UnwindSafe for BufferService<St, Req, Res, Err>
impl<St, Req, Res, Err> Unpin for BufferService<St, Req, Res, Err>
impl<St, Req, Res, Err> UnsafeUnpin for BufferService<St, Req, Res, Err>
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
Source§impl<S, St, Req> IntoService<S, St, Req> for Swhere
S: Service<St, Req>,
impl<S, St, Req> IntoService<S, St, Req> for Swhere
S: Service<St, Req>,
Source§fn into_service(self) -> S
fn into_service(self) -> S
Converts this value into a service.