Vaultx.Base.RateLimiter (Vaultx v0.7.0)
View SourceToken-bucket rate limiter for Vaultx HTTP requests with optional multi-bucket support.
- Each bucket has capacity = rate + burst
- Tokens refill at
rateper second - consume blocks (sleep) until a token is available
Agent state keeps multiple buckets, keyed by an identifier (e.g., host|namespace). If not started (feature disabled), calls become no-ops.
Summary
Functions
Returns a specification to start this module under a supervisor.
Consume 1 token from the default bucket ("default").
Consume 1 token from a named bucket. Uses default rate/burst configured at start.
Consume 1 token from a named bucket with explicit rate and burst. Useful when per-request opts specify rate/burst.
Types
@type bucket() :: %{ rate: pos_integer(), burst: non_neg_integer(), capacity: pos_integer(), tokens: float(), last_refill: integer() }
@type state() :: %{ buckets: %{optional(String.t()) => bucket()}, default_rate: pos_integer(), default_burst: non_neg_integer() }
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
Consume 1 token from the default bucket ("default").
Consume 1 token from a named bucket. Uses default rate/burst configured at start.
Consume 1 token from a named bucket with explicit rate and burst. Useful when per-request opts specify rate/burst.