Struct GlobalConcurrencyLimitLayer

pub struct GlobalConcurrencyLimitLayer { /* private fields */ }

Enforces a limit on the concurrent number of requests the underlying service can handle.

Unlike ConcurrencyLimitLayer, which enforces a per-service concurrency limit, this layer accepts a owned semaphore (Arc<Semaphore>) which can be shared across multiple services.

Cloning this layer will not create a new semaphore.

Implementations

impl GlobalConcurrencyLimitLayer

fn new(max: usize) -> Self

Create a new GlobalConcurrencyLimitLayer.

fn with_semaphore(semaphore: Arc<Semaphore>) -> Self

Create a new GlobalConcurrencyLimitLayer from a Arc<Semaphore>

Trait Implementations

impl Clone for GlobalConcurrencyLimitLayer

fn clone(&self) -> GlobalConcurrencyLimitLayer

impl Debug for GlobalConcurrencyLimitLayer

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

impl<S> Layer<S> for GlobalConcurrencyLimitLayer

type Service = ConcurrencyLimit<S>;
fn layer(&self, service: S) -> Self::Service

Auto Trait Implementations

impl !RefUnwindSafe for GlobalConcurrencyLimitLayer

impl !UnwindSafe for GlobalConcurrencyLimitLayer

impl Freeze for GlobalConcurrencyLimitLayer

impl Send for GlobalConcurrencyLimitLayer

impl Sync for GlobalConcurrencyLimitLayer

impl Unpin for GlobalConcurrencyLimitLayer

impl UnsafeUnpin for GlobalConcurrencyLimitLayer

Blanket Implementations

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

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for GlobalConcurrencyLimitLayer where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for GlobalConcurrencyLimitLayer where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> CloneToUninit for GlobalConcurrencyLimitLayer where T: Clone,

unsafe fn clone_to_uninit(&self, dest: *mut u8)

impl<T> From<T> for GlobalConcurrencyLimitLayer

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> Instrument for GlobalConcurrencyLimitLayer

impl<T> ToOwned for GlobalConcurrencyLimitLayer where T: Clone,

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

impl<T> WithSubscriber for GlobalConcurrencyLimitLayer

impl<T, U> Into<U> for GlobalConcurrencyLimitLayer where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom<U> for GlobalConcurrencyLimitLayer where U: Into<T>,

type Error = never;
fn try_from(value: U) -> Result<T, never>

impl<T, U> TryInto<U> for GlobalConcurrencyLimitLayer where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>