Struct BufferLayer

pub struct BufferLayer<Request> { /* private fields */ }

Adds an mpsc buffer in front of an inner service.

The default Tokio executor is used to run the given service, which means that this layer can only be used on the Tokio runtime.

See the module documentation for more details.

Implementations

impl<Request> BufferLayer<Request>

const fn new(bound: usize) -> Self

Creates a new BufferLayer with the provided bound.

bound gives the maximal number of requests that can be queued for the service before backpressure is applied to callers.

A note on choosing a bound

When Buffer's implementation of poll_ready returns Poll::Ready, it reserves a slot in the channel for the forthcoming call. 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 set bound to be at least the maximum number of concurrent requests the Buffer will see. If you do not, all the slots in the buffer may be held up by futures that have just called poll_ready but will not issue a call, which prevents other senders from issuing new requests.

Trait Implementations

impl<Request> Clone for BufferLayer<Request>

fn clone(&self) -> Self

impl<Request> Copy for BufferLayer<Request>

impl<Request> Debug for BufferLayer<Request>

fn fmt(&self, f: &mut Formatter<'_>) -> Result

impl<S, Request> Layer<S> for BufferLayer<Request> where S: Service<Request> + Send + 'static, S::Future: Send, S::Error: Into<BoxError> + Send + Sync, Request: Send + 'static,

type Service = Buffer<Request, <S as Service<Request>>::Future>;
fn layer(&self, service: S) -> Self::Service

Auto Trait Implementations

impl<Request> Freeze for BufferLayer<Request> where PhantomData<fn(Request)>: Freeze,

impl<Request> RefUnwindSafe for BufferLayer<Request> where PhantomData<fn(Request)>: RefUnwindSafe,

impl<Request> Send for BufferLayer<Request> where PhantomData<fn(Request)>: Send,

impl<Request> Sync for BufferLayer<Request> where PhantomData<fn(Request)>: Sync,

impl<Request> Unpin for BufferLayer<Request> where PhantomData<fn(Request)>: Unpin,

impl<Request> UnsafeUnpin for BufferLayer<Request> where PhantomData<fn(Request)>: UnsafeUnpin,

impl<Request> UnwindSafe for BufferLayer<Request> where PhantomData<fn(Request)>: UnwindSafe,

Blanket Implementations

impl<T> Any for BufferLayer<Request> where T: 'static + ?Sized,

impl<T> Borrow<T> for BufferLayer<Request> where T: ?Sized,

impl<T> BorrowMut<T> for BufferLayer<Request> where T: ?Sized,

impl<T> CloneToUninit for BufferLayer<Request> where T: Clone,

impl<T> From<T> for BufferLayer<Request>

impl<T> Instrument for BufferLayer<Request>

impl<T> ToOwned for BufferLayer<Request> where T: Clone,

impl<T> WithSubscriber for BufferLayer<Request>

impl<T, U> Into<U> for BufferLayer<Request> where U: From<T>,

impl<T, U> TryFrom<U> for BufferLayer<Request> where U: Into<T>,

impl<T, U> TryInto<U> for BufferLayer<Request> where U: TryFrom<T>,