Struct Buffer
struct Buffer<Req, F> { ... }
Adds an mpsc buffer in front of an inner service.
See the module documentation for more details.
Implementations
impl<Req, F> Buffer<Req, F>
fn new<S>(service: S, bound: usize) -> Self where S: Service<Req, Future = F> + Send + 'static, F: Send, <S as >::Error: Into<BoxError> + Send + Sync, Req: Send + 'staticCreates a new
Bufferwrappingservice.boundgives the maximal number of requests that can be queued for the service before backpressure is applied to callers.The default Tokio executor is used to run the given service, which means that this method must be called while on the Tokio runtime.
A note on choosing a
boundWhen
Buffer's implementation ofpoll_readyreturnsPoll::Ready, it reserves a slot in the channel for the forthcomingcall. However, if this call doesn't arrive, this reserved slot may be held up for a long time. As a result, it's advisable to setboundto be at least the maximum number of concurrent requests theBufferwill see. If you do not, all the slots in the buffer may be held up by futures that have just calledpoll_readybut will not issue acall, which prevents other senders from issuing new requests.fn pair<S>(service: S, bound: usize) -> (Self, Worker<S, Req>) where S: Service<Req, Future = F> + Send + 'static, F: Send, <S as >::Error: Into<BoxError> + Send + Sync, Req: Send + 'staticCreates a new
Bufferwrappingservice, 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
Bufferand the backgroundWorkerthat you can then spawn.
impl<M, S, Target, Request> MakeService for Buffer<Req, F>
fn poll_ready(self: &mut Self, cx: &mut Context<'_>) -> Poll<Result<(), <M as MakeService<Target, Request>>::MakeError>>fn make_service(self: &mut Self, target: Target) -> <M as MakeService<Target, Request>>::Future
impl<Req, F> Clone for Buffer<Req, F>
fn clone(self: &Self) -> Self
impl<Req, F> Freeze for Buffer<Req, F>
impl<Req, F> RefUnwindSafe for Buffer<Req, F>
impl<Req, F> Send for Buffer<Req, F>
impl<Req, F> Sync for Buffer<Req, F>
impl<Req, F> Unpin for Buffer<Req, F>
impl<Req, F> UnsafeUnpin for Buffer<Req, F>
impl<Req, F> UnwindSafe for Buffer<Req, F>
impl<Req, Rsp, F, E> Service for Buffer<Req, F>
fn poll_ready(self: &mut Self, cx: &mut Context<'_>) -> Poll<Result<(), <Self as >::Error>>fn call(self: &mut Self, request: Req) -> <Self as >::Future
impl<Req: $crate::fmt::Debug, F: $crate::fmt::Debug> Debug for Buffer<Req, F>
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl<T> Any for Buffer<Req, F>
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for Buffer<Req, F>
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for Buffer<Req, F>
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> CloneToUninit for Buffer<Req, F>
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)
impl<T> From for Buffer<Req, F>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> Instrument for Buffer<Req, F>
impl<T> ToOwned for Buffer<Req, F>
fn to_owned(self: &Self) -> Tfn clone_into(self: &Self, target: &mut T)
impl<T> WithSubscriber for Buffer<Req, F>
impl<T, Request> ServiceExt for Buffer<Req, F>
impl<T, U> Into for Buffer<Req, F>
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for Buffer<Req, F>
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for Buffer<Req, F>
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>