pub struct RateBudget { /* private fields */ }Expand description
Per-instance request and vector budgets over a fixed window.
Implementations§
Source§impl RateBudget
impl RateBudget
Sourcepub fn new(window: Duration, max_requests: u32, max_vectors: u32) -> Self
pub fn new(window: Duration, max_requests: u32, max_vectors: u32) -> Self
max_requests and max_vectors per instance per window.
Sourcepub fn charge_request(&self, instance: &str) -> bool
pub fn charge_request(&self, instance: &str) -> bool
Charge one request (before the body is read).
Sourcepub fn charge_vectors(&self, instance: &str, n: usize) -> bool
pub fn charge_vectors(&self, instance: &str, n: usize) -> bool
Charge n vectors (after the body is validated).
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for RateBudget
impl RefUnwindSafe for RateBudget
impl Send for RateBudget
impl Sync for RateBudget
impl Unpin for RateBudget
impl UnsafeUnpin for RateBudget
impl UnwindSafe for RateBudget
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> 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