pub struct DistributedRateLimit { /* private fields */ }Expand description
A distributed rate limiter: the same window + proxy-trust policy as the
in-process RateLimiter, but the budget lives in a shared
RateLimitStore (e.g. Redis) so it holds
across replicas (ADR 0015). Build one and mount rate_limit_with_store.
Implementations§
Source§impl DistributedRateLimit
impl DistributedRateLimit
Sourcepub fn new(store: Arc<dyn RateLimitStore>, limit: RateLimit) -> Self
pub fn new(store: Arc<dyn RateLimitStore>, limit: RateLimit) -> Self
A distributed limiter over store, enforcing limit per client.
On a store error it defaults to StoreErrorPolicy::FailOpen; call
on_store_error to shed load instead.
Sourcepub fn trusting_forwarded_for(self, trust: bool) -> Self
pub fn trusting_forwarded_for(self, trust: bool) -> Self
Keys on the rightmost X-Forwarded-For entry (single trusted edge only),
exactly as RateLimiter::trusting_forwarded_for.
Sourcepub fn on_store_error(self, policy: StoreErrorPolicy) -> Self
pub fn on_store_error(self, policy: StoreErrorPolicy) -> Self
What to do when the shared store errors (default
StoreErrorPolicy::FailOpen).
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for DistributedRateLimit
impl !UnwindSafe for DistributedRateLimit
impl Forget for DistributedRateLimit
impl Freeze for DistributedRateLimit
impl Move for DistributedRateLimit
impl Send for DistributedRateLimit
impl Sync for DistributedRateLimit
impl Unpin for DistributedRateLimit
impl UnsafeUnpin for DistributedRateLimit
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