pub struct RateLimitConfig {
pub enabled: bool,
pub rps_per_ip: u32,
pub rps_per_user: u32,
pub burst_size: u32,
pub cleanup_interval_secs: u64,
pub trust_proxy_headers: bool,
pub trusted_proxy_cidrs: Vec<IpNet>,
}Expand description
Rate limiting configuration (token-bucket algorithm).
Enforces request-per-second limits per IP/user across all GraphQL operations. This is the canonical rate limiter for request throttling.
Distinct from fraiseql_auth::AuthRateLimitConfig, which uses a
sliding-window algorithm for auth endpoint brute-force protection.
Fields§
§enabled: boolEnable rate limiting
rps_per_ip: u32Requests per second per IP
rps_per_user: u32Requests per second per user (if authenticated)
burst_size: u32Burst capacity (maximum tokens to accumulate)
cleanup_interval_secs: u64Cleanup interval in seconds (remove stale entries)
trust_proxy_headers: boolTrust X-Real-IP / X-Forwarded-For headers for client IP extraction.
Must only be enabled when behind a trusted reverse proxy.
trusted_proxy_cidrs: Vec<IpNet>Parsed CIDR ranges trusted as proxy IPs.
When non-empty, X-Forwarded-For is only trusted if the direct connection IP
falls within one of these ranges. An empty Vec with trust_proxy_headers = true
means all direct IPs are treated as trusted proxies (less secure).
Implementations§
Source§impl RateLimitConfig
impl RateLimitConfig
Sourcepub fn from_security_config(sec: &RateLimitingSecurityConfig) -> Self
pub fn from_security_config(sec: &RateLimitingSecurityConfig) -> Self
Build from the [security.rate_limiting] config embedded in the compiled schema.
Maps requests_per_second → rps_per_ip and burst_size directly.
rps_per_user uses the explicit requests_per_second_per_user value when set,
or defaults to 10× requests_per_second.
The default 10× multiplier reflects that authenticated users are identifiable
(abuse is traceable) and include service accounts with higher call rates.
Operators can override with requests_per_second_per_user in fraiseql.toml.
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
Source§impl Default for RateLimitConfig
impl Default for RateLimitConfig
Source§impl<'de> Deserialize<'de> for RateLimitConfig
impl<'de> Deserialize<'de> for RateLimitConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
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