# `Alternera.Plugin.Provisional.Rate`
[🔗](https://github.com/10e-ab/alternera-sdk/blob/v0.9.0/alternera_plugin_sdk/lib/alternera/plugin/provisional/rate.ex#L1)

Provisional: added for Rate limit, and a change to it needs a changelog line
but no new major (`docs/USER_PLUGINS_DESIGN.md`).

A rate counted per key, through `Alternera.Plugin.Host`: `check/3`
counts one request of `key` against `rate` and answers `:ok`, or
`{:refuse, retry_in_ms}` when the key is over it. The proxy counts with the
counter its usage plans use (generic cell rate: `burst` pass at once after a
quiet spell, then one every `per_seconds / requests`), per node.

The counts are the step's own: the host keeps them under the tenant and the
step (its pipeline and id, from the context), so two steps never share
counts and a usage plan's counts are apart from every step's. A plugin names
only the key within them.

# `rate`

```elixir
@type rate() :: %{
  requests: pos_integer(),
  per_seconds: pos_integer(),
  burst: pos_integer()
}
```

A rate: `requests` per `per_seconds`, `burst` at once.

# `check`

```elixir
@spec check(map(), String.t(), rate()) :: :ok | {:refuse, pos_integer()}
```

Counts one request of `key` against `rate`, in the step's own counts.

---

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