# `Wise.Internal.RateLimiter`
[🔗](https://github.com/iamkanishka/wise/blob/v1.0.0/lib/wise/internal/rate_limiter.ex#L1)

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)

# `state`

```elixir
@type state() :: %{
  tokens: float(),
  max_tokens: float(),
  refill_rate: float(),
  last_refill: integer()
}
```

Rate limiter state

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `start_link`

```elixir
@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

# `wait`

```elixir
@spec wait(GenServer.server(), timeout()) :: :ok | {:error, :timeout}
```

Blocks until a token is available. Returns `:ok` or `{:error, :timeout}`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
