Propagates an instance's bans across a cluster of nodes.
By default all of an instance's state is per node, which works well behind a load balancer: rates and limits are approximate per node anyway. Bans are different: a client banned on one node should be banned everywhere. With
config :my_app, Limen, cluster: [enabled: true]the instance runs this process in a dedicated :pg scope (Erlang's
distributed process groups), named after the instance unless :scope says
otherwise, so instances of the same name on
different nodes share their bans and other instances never see them. Bans
and unbans made on a node (by policies or with Limen.ban/4) are queued in
an ETS outbox on the request path, and this process broadcasts the queue to
the other nodes every :interval milliseconds. Received bans keep their
absolute expiry, so node clocks should be roughly in sync (NTP). Counters
stay local.
Nothing on the request path talks to this process; it only reads and writes ETS.
Summary
Functions
Returns a specification to start this module under a supervisor.
Broadcasts the queued bans of instance now and waits until it is done.
The other nodes currently receiving the bans of instance.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec flush(atom()) :: :ok
Broadcasts the queued bans of instance now and waits until it is done.
The other nodes currently receiving the bans of instance.