# `Hammer.Atomic`
[🔗](https://github.com/ExHammer/hammer/blob/v7.2.0/lib/hammer/atomic.ex#L1)

A rate limiter implementation using Erlang's :atomics module for atomic counters.

This provides fast, atomic counter operations without the overhead of ETS or process messaging.
Requires Erlang/OTP 21.2 or later.

The atomic backend supports the following algorithms:

- `:fix_window` - Fixed window rate limiting (default)
  Simple counting within fixed time windows. See [Hammer.Atomic.FixWindow](Hammer.Atomic.FixWindow.html) for more details.

- `:leaky_bucket` - Leaky bucket rate limiting
  Smooth rate limiting with a fixed rate of tokens. See [Hammer.Atomic.LeakyBucket](Hammer.Atomic.LeakyBucket.html) for more details.

- `:token_bucket` - Token bucket rate limiting
  Flexible rate limiting with bursting capability. See [Hammer.Atomic.TokenBucket](Hammer.Atomic.TokenBucket.html) for more details.

# `config`

```elixir
@type config() :: %{
  table: atom(),
  table_opts: list(),
  clean_period: pos_integer(),
  key_older_than: pos_integer(),
  algorithm: module()
}
```

# `start_option`

```elixir
@type start_option() ::
  {:clean_period, pos_integer()}
  | {:key_older_than, pos_integer()}
  | GenServer.option()
```

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `now`

```elixir
@spec now() :: pos_integer()
```

Returns the current time in milliseconds.

# `start_link`

```elixir
@spec start_link([start_option()]) :: GenServer.on_start()
```

Starts the atomic rate limiter process.

Options:
- `:clean_period` - How often to run cleanup (ms). Default 1 minute.
- `:key_older_than` - Max age for entries (ms). Default 24 hours.

---

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