pub struct RateLimitParams {
pub algorithm: DistributedAlgorithm,
pub rate: f64,
pub burst: f64,
pub window_secs: u64,
}Expand description
Immutable parameters describing how a key should be rate limited.
Derived from a RateLimitConfig via RateLimitParams::from_config.
Backends use these to perform the refill / windowing math atomically.
Fields§
§algorithm: DistributedAlgorithmAlgorithm to apply.
rate: f64Refill rate in tokens (or events) per second.
burst: f64Maximum burst capacity (token bucket) — tokens never exceed this.
window_secs: u64Window size in seconds (sliding window).
Implementations§
Source§impl RateLimitParams
impl RateLimitParams
Sourcepub fn from_config(config: &RateLimitConfig) -> Self
pub fn from_config(config: &RateLimitConfig) -> Self
Build parameters from a RateLimitConfig, reusing its algorithm choice
and effective burst computation so behaviour matches the in-process
limiters exactly.
Sourcepub fn max_window_events(&self) -> u64
pub fn max_window_events(&self) -> u64
Maximum number of events permitted within the sliding window.
Trait Implementations§
Source§impl Clone for RateLimitParams
impl Clone for RateLimitParams
impl Copy for RateLimitParams
Source§impl Debug for RateLimitParams
impl Debug for RateLimitParams
Source§impl PartialEq for RateLimitParams
impl PartialEq for RateLimitParams
impl StructuralPartialEq for RateLimitParams
Auto Trait Implementations§
impl Freeze for RateLimitParams
impl RefUnwindSafe for RateLimitParams
impl Send for RateLimitParams
impl Sync for RateLimitParams
impl Unpin for RateLimitParams
impl UnsafeUnpin for RateLimitParams
impl UnwindSafe for RateLimitParams
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