pub struct Gcra { /* private fields */ }Expand description
A GCRA limiter parameterised by a steady emission interval and a burst
tolerance. Construct one from a Profile with Gcra::from_profile.
Implementations§
Source§impl Gcra
impl Gcra
Sourcepub fn from_profile(profile: Profile) -> Self
pub fn from_profile(profile: Profile) -> Self
Build a limiter from a Profile. burst is clamped to at least 1 and
rate to at least 1 so the emission interval is finite.
Sourcepub fn check(&self, stored_tat: Option<Duration>, now: Duration) -> Verdict
pub fn check(&self, stored_tat: Option<Duration>, now: Duration) -> Verdict
Evaluate a request arriving at now (a monotonically-increasing instant
expressed as a Duration since a fixed epoch), given the key’s stored
TAT (None for a first-seen key).
A now that moves backwards (clock skew) is tolerated: the check never
panics and treats the effective arrival time as max(now, tat_floor).
Trait Implementations§
impl Copy for Gcra
impl Eq for Gcra
impl StructuralPartialEq for Gcra
Auto Trait Implementations§
impl Freeze for Gcra
impl RefUnwindSafe for Gcra
impl Send for Gcra
impl Sync for Gcra
impl Unpin for Gcra
impl UnsafeUnpin for Gcra
impl UnwindSafe for Gcra
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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> 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