# `Foundation.RateLimit.BackoffWindow`
[🔗](https://github.com/nshkrdotcom/foundation/blob/v0.2.1/lib/foundation/rate_limit/backoff_window.ex#L1)

Shared backoff windows keyed by arbitrary identifiers.

# `limiter`
[🔗](https://github.com/nshkrdotcom/foundation/blob/v0.2.1/lib/foundation/rate_limit/backoff_window.ex#L11)

```elixir
@type limiter() :: :atomics.atomics_ref()
```

# `registry`
[🔗](https://github.com/nshkrdotcom/foundation/blob/v0.2.1/lib/foundation/rate_limit/backoff_window.ex#L10)

```elixir
@type registry() :: :ets.tid() | atom()
```

# `clear`
[🔗](https://github.com/nshkrdotcom/foundation/blob/v0.2.1/lib/foundation/rate_limit/backoff_window.ex#L83)

```elixir
@spec clear(limiter()) :: :ok
```

Clear any active backoff window.

# `default_registry`
[🔗](https://github.com/nshkrdotcom/foundation/blob/v0.2.1/lib/foundation/rate_limit/backoff_window.ex#L17)

```elixir
@spec default_registry() :: registry()
```

Return the default registry (anonymous ETS table).

# `for_key`
[🔗](https://github.com/nshkrdotcom/foundation/blob/v0.2.1/lib/foundation/rate_limit/backoff_window.ex#L31)

```elixir
@spec for_key(term()) :: limiter()
```

Get or create a limiter for the given key in the default registry.

# `for_key`
[🔗](https://github.com/nshkrdotcom/foundation/blob/v0.2.1/lib/foundation/rate_limit/backoff_window.ex#L37)

```elixir
@spec for_key(registry(), term()) :: limiter()
```

Get or create a limiter for the given key in the provided registry.

# `new_registry`
[🔗](https://github.com/nshkrdotcom/foundation/blob/v0.2.1/lib/foundation/rate_limit/backoff_window.ex#L25)

```elixir
@spec new_registry(keyword()) :: registry()
```

Create a new registry. Use `name: :my_table` for a named ETS table.

# `set`
[🔗](https://github.com/nshkrdotcom/foundation/blob/v0.2.1/lib/foundation/rate_limit/backoff_window.ex#L72)

```elixir
@spec set(limiter(), non_neg_integer(), keyword()) :: :ok
```

Set a backoff window in milliseconds.

# `should_backoff?`
[🔗](https://github.com/nshkrdotcom/foundation/blob/v0.2.1/lib/foundation/rate_limit/backoff_window.ex#L61)

```elixir
@spec should_backoff?(
  limiter(),
  keyword()
) :: boolean()
```

Determine whether a limiter is currently in a backoff window.

# `wait`
[🔗](https://github.com/nshkrdotcom/foundation/blob/v0.2.1/lib/foundation/rate_limit/backoff_window.ex#L92)

```elixir
@spec wait(
  limiter(),
  keyword()
) :: :ok
```

Block until the backoff window has passed.

---

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