pub struct RequestLimiter(/* private fields */);Expand description
Shared admission limit. Defaults share a process-wide pool of 64 requests.
Clones share the same pool. Admission rejects excess requests immediately
with AgError::Overloaded. A cancelled request’s running blocking work
retains its permit until that work exits.
Implementations§
Source§impl RequestLimiter
impl RequestLimiter
Sourcepub fn new(max_in_flight: usize) -> Self
pub fn new(max_in_flight: usize) -> Self
Create an independent pool, clamping capacity to 1..=Semaphore::MAX_PERMITS.
Use Default::default to join the process-wide pool instead.
Sourcepub fn available_permits(&self) -> usize
pub fn available_permits(&self) -> usize
Snapshot the currently unoccupied capacity, shared by all clones.
Trait Implementations§
Source§impl Clone for RequestLimiter
impl Clone for RequestLimiter
Source§impl Debug for RequestLimiter
impl Debug for RequestLimiter
Auto Trait Implementations§
impl !RefUnwindSafe for RequestLimiter
impl !UnwindSafe for RequestLimiter
impl Freeze for RequestLimiter
impl Send for RequestLimiter
impl Sync for RequestLimiter
impl Unpin for RequestLimiter
impl UnsafeUnpin for RequestLimiter
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more