Struct ConcurrencyLimit
pub struct ConcurrencyLimit<T> { /* private fields */ }
Enforces a limit on the concurrent number of requests the underlying service can handle.
Implementations
impl<T> ConcurrencyLimit<T>
fn new(inner: T, max: usize) -> SelfCreate a new concurrency limiter.
fn with_semaphore(inner: T, semaphore: Arc<Semaphore>) -> SelfCreate a new concurrency limiter with a provided shared semaphore
fn get_ref(&self) -> &TGet a reference to the inner service
fn get_mut(&mut self) -> &mut TGet a mutable reference to the inner service
fn into_inner(self) -> TConsume
self, returning the inner service
Trait Implementations
impl<S> Load for ConcurrencyLimit<S>
where
S: Load,
type Metric = <S as Load>::Metric;fn load(&self) -> Self::Metric
impl<S, Request> Service<Request> for ConcurrencyLimit<S>
where
S: Service<Request>,
type Response = <S as Service<Request>>::Response;type Error = <S as Service<Request>>::Error;type Future = ResponseFuture<<S as Service<Request>>::Future>;fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>fn call(&mut self, request: Request) -> Self::Future
impl<T: Clone> Clone for ConcurrencyLimit<T>
fn clone(&self) -> Self
impl<T: Debug> Debug for ConcurrencyLimit<T>
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Auto Trait Implementations
impl<T> !RefUnwindSafe for ConcurrencyLimit<T>
impl<T> !UnwindSafe for ConcurrencyLimit<T>
impl<T> Freeze for ConcurrencyLimit<T>
where
T: Freeze,
impl<T> Send for ConcurrencyLimit<T>
where
T: Send,
impl<T> Sync for ConcurrencyLimit<T>
where
T: Sync,
impl<T> Unpin for ConcurrencyLimit<T>
where
T: Unpin,
impl<T> UnsafeUnpin for ConcurrencyLimit<T>
where
T: UnsafeUnpin,
Blanket Implementations
impl<C, Target> MakeConnection<Target> for ConcurrencyLimit<T>
where
C: Service<Target>,
<C as Service<Target>>::Response: AsyncRead + AsyncWrite,
type Connection = <C as Service<Target>>::Response;type Error = <C as Service<Target>>::Error;type Future = <C as Service<Target>>::Future;fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), <C as MakeConnection<Target>>::Error>>fn make_connection(&mut self, target: Target) -> <C as MakeConnection<Target>>::Future
impl<M, S, Target, Request> MakeService<Target, Request> for ConcurrencyLimit<T>
where
M: Service<Target, Response = S>,
S: Service<Request>,
type Response = <S as Service<Request>>::Response;type Error = <S as Service<Request>>::Error;type Service = S;type MakeError = <M as Service<Target>>::Error;type Future = <M as Service<Target>>::Future;fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), <M as MakeService<Target, Request>>::MakeError>>fn make_service(&mut self, target: Target) -> <M as MakeService<Target, Request>>::Future
impl<T> Any for ConcurrencyLimit<T>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for ConcurrencyLimit<T>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for ConcurrencyLimit<T>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for ConcurrencyLimit<T>
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> From<T> for ConcurrencyLimit<T>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> Instrument for ConcurrencyLimit<T>
impl<T> ToOwned for ConcurrencyLimit<T>
where
T: Clone,
type Owned = T;fn to_owned(&self) -> Tfn clone_into(&self, target: &mut T)
impl<T> WithSubscriber for ConcurrencyLimit<T>
impl<T, Request> ServiceExt<Request> for ConcurrencyLimit<T>
where
T: Service<Request> + ?Sized,
impl<T, U> Into<U> for ConcurrencyLimit<T>
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for ConcurrencyLimit<T>
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for ConcurrencyLimit<T>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>