pub struct RateLimit { /* private fields */ }Expand description
The sharded counters, and the process-random hash that decides which bucket an actor lands in.
Implementations§
Source§impl RateLimit
impl RateLimit
pub fn new(quota: Quota) -> RateLimit
pub fn quota(&self) -> Quota
Sourcepub fn admit(&self, actor: &str, now_ms: i64) -> bool
pub fn admit(&self, actor: &str, now_ms: i64) -> bool
Charge one event to this actor, and say whether it is allowed.
now_ms is passed in rather than read, for the reason Proposal::at is: the merge point is
the one place time enters, and it enters from the clock the process was configured with
(§3.7, F11). A quota that read the wall clock itself would be a second, ambient one.
Auto Trait Implementations§
impl Freeze for RateLimit
impl RefUnwindSafe for RateLimit
impl Send for RateLimit
impl Sync for RateLimit
impl Unpin for RateLimit
impl UnwindSafe for RateLimit
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