View Source Hammer.Atomic (hammer v7.0.0-rc.3)
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.
Summary
Functions
Returns a specification to start this module under a supervisor.
Returns the current time in milliseconds.
Starts the atomic rate limiter process.
Types
@type config() :: %{ table: atom(), table_opts: list(), clean_period: pos_integer(), key_older_than: pos_integer(), algorithm: module() }
@type start_option() :: {:clean_period, pos_integer()} | {:key_older_than, pos_integer()} | GenServer.option()
Functions
Returns a specification to start this module under a supervisor.
See Supervisor
.
@spec now() :: pos_integer()
Returns the current time in milliseconds.
@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.