Token-bucket rate limiter backed by a GenServer.
Provides sustained throughput control for outbound API requests. The default bucket allows 10 requests per second with a burst of 20.
Usage
{:ok, _pid} = Wise.Internal.RateLimiter.start_link(rate: 10, burst: 20)
:ok = Wise.Internal.RateLimiter.wait(pid)
Summary
Functions
Returns a specification to start this module under a supervisor.
Starts a rate limiter process.
Blocks until a token is available. Returns :ok or {:error, :timeout}.
Types
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec start_link(keyword()) :: GenServer.on_start()
Starts a rate limiter process.
Options
:rate- sustained requests per second (default: 10):burst- maximum burst capacity (default: 20):name- GenServer registration name
@spec wait(GenServer.server(), timeout()) :: :ok | {:error, :timeout}
Blocks until a token is available. Returns :ok or {:error, :timeout}.