pub struct RateLimitConfig {
pub default: EndpointRateLimit,
pub per_endpoint: IndexMap<String, RateLimitRule>,
pub storage: Option<Arc<dyn RateLimitStorage>>,
pub max_buckets: usize,
pub enabled: bool,
}Expand description
Configuration for the rate limiting middleware.
Fields§
§default: EndpointRateLimitDefault limit for endpoints without a built-in special rule or custom override.
per_endpoint: IndexMap<String, RateLimitRule>Ordered path overrides. The first matching rule wins.
storage: Option<Arc<dyn RateLimitStorage>>Shared atomic storage; absent selects bounded process-local memory.
max_buckets: usizeMaximum live client/path buckets. New buckets fail closed at capacity.
enabled: boolWhether rate limiting is enabled.
Implementations§
Source§impl RateLimitConfig
impl RateLimitConfig
pub fn new() -> Self
pub fn default_limit(self, window: Duration, max_requests: u32) -> Self
pub fn endpoint( self, path: impl Into<String>, window: Duration, max_requests: u32, ) -> Self
pub fn rule(self, path: impl Into<String>, rule: RateLimitRule) -> Self
pub fn storage(self, storage: Arc<dyn RateLimitStorage>) -> Self
Sourcepub const fn max_buckets(self, maximum: usize) -> Self
pub const fn max_buckets(self, maximum: usize) -> Self
Bound memory without evicting active clients and resetting their quotas.
pub const fn enabled(self, enabled: bool) -> Self
Trait Implementations§
Source§impl Clone for RateLimitConfig
impl Clone for RateLimitConfig
Source§impl Debug for RateLimitConfig
impl Debug for RateLimitConfig
Auto Trait Implementations§
impl !RefUnwindSafe for RateLimitConfig
impl !UnwindSafe for RateLimitConfig
impl Freeze for RateLimitConfig
impl Send for RateLimitConfig
impl Sync for RateLimitConfig
impl Unpin for RateLimitConfig
impl UnsafeUnpin for RateLimitConfig
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