pub struct RateLimiterConfig<K: KeyExtractor> { /* private fields */ }Expand description
Rate-limiter configuration: a shared quota + key extractor, cheap to
clone (the limiter is behind an Arc) so the SAME bucket state is reused
across every App factory invocation (actix spins up one App per
worker thread) — mirrors actix_governor::GovernorConfig.
Implementations§
Source§impl<K: KeyExtractor> RateLimiterConfig<K>
impl<K: KeyExtractor> RateLimiterConfig<K>
Sourcepub fn new(period: Duration, burst_size: u32, key_extractor: K) -> Self
pub fn new(period: Duration, burst_size: u32, key_extractor: K) -> Self
Build a config allowing bursts up to burst_size, replenishing one
quota element every period. Mirrors
GovernorConfigBuilder::{milliseconds_per_request,burst_size}.finish()
(same Quota::with_period(..).allow_burst(..) construction).
Panics if period is zero or burst_size is zero, same as
finish() returning None did — callers clamp beforehand (see
config::rate_limiter_config).
Trait Implementations§
Source§impl<K: KeyExtractor> Clone for RateLimiterConfig<K>
impl<K: KeyExtractor> Clone for RateLimiterConfig<K>
Auto Trait Implementations§
impl<K> !RefUnwindSafe for RateLimiterConfig<K>
impl<K> !UnwindSafe for RateLimiterConfig<K>
impl<K> Freeze for RateLimiterConfig<K>where
K: Freeze,
impl<K> Send for RateLimiterConfig<K>where
K: Send,
impl<K> Sync for RateLimiterConfig<K>where
K: Sync,
impl<K> Unpin for RateLimiterConfig<K>where
K: Unpin,
impl<K> UnsafeUnpin for RateLimiterConfig<K>where
K: UnsafeUnpin,
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