pub struct RateLimitConfig {Show 17 fields
pub enabled: bool,
pub default_qps: u32,
pub default_burst: u32,
pub default_concurrency: u32,
pub exceeded_action: ExceededAction,
pub retry_after: bool,
pub overrides: HashMap<LimiterKey, LimitOverride>,
pub user_limits_enabled: bool,
pub database_limits_enabled: bool,
pub client_ip_limits_enabled: bool,
pub pattern_limits_enabled: bool,
pub queue_max_wait: Duration,
pub queue_size: u32,
pub replication_throttle_threshold: Option<Duration>,
pub cleanup_interval: Duration,
pub priority_multipliers: HashMap<PriorityLevel, f32>,
pub cost_estimation_enabled: bool,
}Expand description
Main rate limit configuration
Fields§
§enabled: boolWhether rate limiting is enabled
default_qps: u32Default queries per second
default_burst: u32Default burst capacity
default_concurrency: u32Default max concurrent queries
exceeded_action: ExceededActionAction when limit exceeded
retry_after: boolWhether to include Retry-After header
overrides: HashMap<LimiterKey, LimitOverride>Per-key overrides
user_limits_enabled: boolEnable per-user limits
database_limits_enabled: boolEnable per-database limits
client_ip_limits_enabled: boolEnable per-client-IP limits
pattern_limits_enabled: boolEnable per-query-pattern limits
queue_max_wait: DurationQueue configuration
queue_size: u32§replication_throttle_threshold: Option<Duration>Replication throttle threshold (lag duration)
cleanup_interval: DurationCleanup interval for expired entries
priority_multipliers: HashMap<PriorityLevel, f32>Priority multipliers (higher priority = higher effective limit)
cost_estimation_enabled: boolCost estimation enabled
Implementations§
Source§impl RateLimitConfig
impl RateLimitConfig
Sourcepub fn builder() -> RateLimitConfigBuilder
pub fn builder() -> RateLimitConfigBuilder
Create a builder for configuration
Sourcepub fn effective_qps(&self, key: &LimiterKey, priority: PriorityLevel) -> u32
pub fn effective_qps(&self, key: &LimiterKey, priority: PriorityLevel) -> u32
Get effective QPS for a key, considering overrides
Sourcepub fn effective_burst(&self, key: &LimiterKey, priority: PriorityLevel) -> u32
pub fn effective_burst(&self, key: &LimiterKey, priority: PriorityLevel) -> u32
Get effective burst for a key
Sourcepub fn effective_concurrency(
&self,
key: &LimiterKey,
priority: PriorityLevel,
) -> u32
pub fn effective_concurrency( &self, key: &LimiterKey, priority: PriorityLevel, ) -> u32
Get effective max concurrent for a key
Sourcepub fn action_for_key(&self, key: &LimiterKey) -> ExceededAction
pub fn action_for_key(&self, key: &LimiterKey) -> ExceededAction
Get action for a key
Sourcepub fn add_override(&mut self, key: LimiterKey, override_: LimitOverride)
pub fn add_override(&mut self, key: LimiterKey, override_: LimitOverride)
Add an override for a key
Sourcepub fn remove_override(&mut self, key: &LimiterKey) -> Option<LimitOverride>
pub fn remove_override(&mut self, key: &LimiterKey) -> Option<LimitOverride>
Remove an override
Sourcepub fn cleanup_expired(&mut self)
pub fn cleanup_expired(&mut self)
Clean up expired overrides
Trait Implementations§
Source§impl Clone for RateLimitConfig
impl Clone for RateLimitConfig
Source§fn clone(&self) -> RateLimitConfig
fn clone(&self) -> RateLimitConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RateLimitConfig
impl Debug for RateLimitConfig
Auto Trait Implementations§
impl Freeze for RateLimitConfig
impl RefUnwindSafe for RateLimitConfig
impl Send for RateLimitConfig
impl Sync for RateLimitConfig
impl Unpin for RateLimitConfig
impl UnsafeUnpin for RateLimitConfig
impl UnwindSafe 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more