pub struct ConcurrencyLimit { /* private fields */ }Expand description
Allow at most max requests in flight, answer the rest with 503 and Retry-After
By default an excess request is rejected at once. ConcurrencyLimit::queue_for
lets it wait a short while for a free slot first, which smooths bursts without
building an unbounded backlog.
Implementations§
Source§impl ConcurrencyLimit
impl ConcurrencyLimit
pub fn new(max: usize) -> Self
Sourcepub fn queue_for(self, wait: Duration) -> Self
pub fn queue_for(self, wait: Duration) -> Self
Let an excess request wait up to wait for a slot before it is rejected
Sourcepub fn retry_after(self, seconds: u64) -> Self
pub fn retry_after(self, seconds: u64) -> Self
Seconds advertised in Retry-After (default 1)
Sourcepub fn available_slots(&self) -> usize
pub fn available_slots(&self) -> usize
Requests that currently hold a slot is max - available_slots()
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for ConcurrencyLimit
impl !UnwindSafe for ConcurrencyLimit
impl Freeze for ConcurrencyLimit
impl Send for ConcurrencyLimit
impl Sync for ConcurrencyLimit
impl Unpin for ConcurrencyLimit
impl UnsafeUnpin for ConcurrencyLimit
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