pub struct RateLimitConfig {
pub capacity: u64,
pub refill_per_sec: u64,
pub key: KeyConfig,
pub caps: CapsConfig,
pub retry_after_ms: Option<u64>,
}Expand description
Typed config surface for the rate_limit middleware (token bucket).
Fields§
§capacity: u64Token bucket capacity (burst). Required.
refill_per_sec: u64Steady-state refill rate in tokens per second. Required.
key: KeyConfigKey-extraction strategy. Flattened so key = "header" + header_name
sit at the top level, matching the historical spec.
caps: CapsConfigPer-key bucket-map caps.
retry_after_ms: Option<u64>Retry-After (ms) advertised on a 429. None keeps the limiter default.
Implementations§
Source§impl RateLimitConfig
impl RateLimitConfig
Sourcepub fn builder() -> RateLimitConfigBuilder
pub fn builder() -> RateLimitConfigBuilder
Create an instance of RateLimitConfig using the builder syntax
Source§impl RateLimitConfig
impl RateLimitConfig
Sourcepub fn from_config(
self,
inner: PipeHandle,
) -> Result<RateLimit<PipeHandle, KeyExtractor, TimeClock>, ProximaError>
pub fn from_config( self, inner: PipeHandle, ) -> Result<RateLimit<PipeHandle, KeyExtractor, TimeClock>, ProximaError>
Materialise the limiter around inner, on the production TimeClock.
Trait Implementations§
Source§impl Clone for RateLimitConfig
impl Clone for RateLimitConfig
Source§impl Debug for RateLimitConfig
impl Debug 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>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for RateLimitConfig
impl Serialize for RateLimitConfig
Source§impl Settings for RateLimitConfig
impl Settings for RateLimitConfig
Source§const PREFIX: Option<&'static str>
const PREFIX: Option<&'static str>
The struct’s own prefix, used only when it is the root of resolution.
When embedded as a nested field, the embedding field decides the prefix.
Source§fn from_env_with_prefix(__prefix: &str) -> Result<Self>
fn from_env_with_prefix(__prefix: &str) -> Result<Self>
Resolve using
prefix as the accumulated root instead of PREFIX.
Used by parent structs to push their namespace into nested fields.Source§fn override_from_env(&mut self) -> Result<()>
fn override_from_env(&mut self) -> Result<()>
Overwrite only the fields whose env keys are currently set, leaving the
rest untouched. Useful for layering env over file-loaded defaults.
Source§fn override_from_env_with_prefix(&mut self, __prefix: &str) -> Result<()>
fn override_from_env_with_prefix(&mut self, __prefix: &str) -> Result<()>
override_from_env with an explicit accumulated prefix.Source§impl Validate for RateLimitConfig
impl Validate 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
Mutably borrows from an owned value. Read more