pub struct ProbRateLimiter { /* private fields */ }Expand description
A probabilistic rate-limiter.
- When not overloaded, accepts all requests
- As load approaches limit, probabilistically rejects more and more requests.
- Onset of overload does not trigger a sudden total outage.
Implementations§
Source§impl ProbRateLimiter
impl ProbRateLimiter
Sourcepub fn new_custom(
tick_duration: Duration,
max_cost_per_tick: u32,
now: Instant,
prng: Rand32,
) -> Result<Self, String>
pub fn new_custom( tick_duration: Duration, max_cost_per_tick: u32, now: Instant, prng: Rand32, ) -> Result<Self, String>
Makes a new rate limiter that accepts max_cost_per_tick every tick_duration.
§Errors
Returns an error when tick_duration is less than 1 microsecond.
Sourcepub fn new(max_cost_per_sec: u32) -> Self
pub fn new(max_cost_per_sec: u32) -> Self
Makes a new rate limiter that accepts max_cost_per_sec cost every second.
Trait Implementations§
Source§impl Clone for ProbRateLimiter
impl Clone for ProbRateLimiter
Source§fn clone(&self) -> ProbRateLimiter
fn clone(&self) -> ProbRateLimiter
Returns a duplicate of the value. Read more
1.0.0 · 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 ProbRateLimiter
impl RefUnwindSafe for ProbRateLimiter
impl Send for ProbRateLimiter
impl Sync for ProbRateLimiter
impl Unpin for ProbRateLimiter
impl UnwindSafe for ProbRateLimiter
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