pub struct PrincipalConnectionLimiter { /* private fields */ }Implementations§
Source§impl PrincipalConnectionLimiter
impl PrincipalConnectionLimiter
Sourcepub fn new(cap: usize) -> Self
pub fn new(cap: usize) -> Self
Build a limiter with the given per-principal concurrent in-flight
cap. 0 disables enforcement.
Sourcepub fn is_enforced(&self) -> bool
pub fn is_enforced(&self) -> bool
true when enforcement is active (cap > 0).
Sourcepub fn current_for(&self, principal: &str) -> usize
pub fn current_for(&self, principal: &str) -> usize
Live in-flight count for a single principal (0 if it holds none).
Observability only.
Sourcepub fn tracked_principals(&self) -> usize
pub fn tracked_principals(&self) -> usize
Number of principals currently holding at least one permit.
Sourcepub fn rejected_total(&self) -> u64
pub fn rejected_total(&self) -> u64
Total refusals issued since construction. Surfaced via
reddb_http_principal_inflight_rejected_total.
Sourcepub fn try_acquire(
&self,
principal: &str,
) -> Result<PrincipalInflightPermit, PrincipalCapExceeded>
pub fn try_acquire( &self, principal: &str, ) -> Result<PrincipalInflightPermit, PrincipalCapExceeded>
Admit one in-flight request for principal. Returns Ok(permit)
when the principal is under its cap (slot reserved, released on
permit drop) or Err(PrincipalCapExceeded) when it is already at
the cap. A disabled limiter (cap 0) always admits and never
touches the map.
Trait Implementations§
Source§impl Clone for PrincipalConnectionLimiter
impl Clone for PrincipalConnectionLimiter
Source§fn clone(&self) -> PrincipalConnectionLimiter
fn clone(&self) -> PrincipalConnectionLimiter
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for PrincipalConnectionLimiter
impl RefUnwindSafe for PrincipalConnectionLimiter
impl Send for PrincipalConnectionLimiter
impl Sync for PrincipalConnectionLimiter
impl Unpin for PrincipalConnectionLimiter
impl UnsafeUnpin for PrincipalConnectionLimiter
impl UnwindSafe for PrincipalConnectionLimiter
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request