pub struct RateLimitState(/* private fields */);Expand description
Shared, non-reloadable rate-limit store handle. Lives outside the module so
a config hot reload (Fase 6 / Pillar 3) rebuilds the module’s parameters
(capacity/refill/action) while the buckets survive — otherwise an attacker
could clear their own throttle by triggering a reload. Holds an
Arc<dyn StateStore> so the enterprise can inject a distributed store without
forking (the seam of BOUNDARY §4).
Implementations§
Source§impl RateLimitState
impl RateLimitState
Sourcepub fn in_memory(max_tracked_keys: usize) -> Self
pub fn in_memory(max_tracked_keys: usize) -> Self
In-memory store with an explicit tracked-key cap (system clock).
Sourcepub fn in_memory_with_clock(
clock: Arc<dyn Clock>,
max_tracked_keys: usize,
) -> Self
pub fn in_memory_with_clock( clock: Arc<dyn Clock>, max_tracked_keys: usize, ) -> Self
In-memory store with a custom clock + cap (deterministic tests).
Sourcepub fn with_store(store: Arc<dyn StateStore>) -> Self
pub fn with_store(store: Arc<dyn StateStore>) -> Self
Wrap an arbitrary store (the enterprise injection point).
Sourcepub fn try_acquire(
&self,
key: &str,
cost: f64,
params: BucketParams,
) -> Acquired
pub fn try_acquire( &self, key: &str, cost: f64, params: BucketParams, ) -> Acquired
Delegate one atomic acquire to the underlying store. Exists so consumers in other crates (the rate-limit module) reach the store without touching the private handle — the store stays the single owner of the bucket state.
Trait Implementations§
Source§impl Clone for RateLimitState
impl Clone for RateLimitState
Source§fn clone(&self) -> RateLimitState
fn clone(&self) -> RateLimitState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more