View Source Plausible.RateLimit (Plausible v0.0.1)
Thin wrapper around :ets.update_counter/4
and a
clean-up process to act as a rate limiter.
Summary
Functions
Checks the rate-limit for a key.
Returns a specification to start this module under a supervisor.
Starts the process that creates and cleans the ETS table.
Functions
Link to this function
check_rate(table \\ __MODULE__, key, scale, limit, increment \\ 1)
View Source@spec check_rate(:ets.table(), key, scale, limit, increment) :: {:allow, count} | {:deny, limit} when key: term(), scale: pos_integer(), limit: pos_integer(), increment: pos_integer(), count: pos_integer()
Checks the rate-limit for a key.
Returns a specification to start this module under a supervisor.
See Supervisor
.
@spec start_link([ GenServer.option() | {:table, atom()} | {:clean_period, pos_integer()} ]) :: GenServer.on_start()
Starts the process that creates and cleans the ETS table.
Accepts the following options:
GenServer.options()
:table
for the ETS table name, defaults toElixir.Plausible.RateLimit
:clean_period
for how often to perform garbage collection