ex_limiter v1.3.8 ExLimiter.Storage.PG2Shard View Source
Implements the leaky bucket using a fleet of GenServers discoverable via a pg2 group.
To configure the pool size, do:
config :ex_limit, ExLimiter.Storage.PG2Shard,
shard_count: 20
You must also include the shard supervisor in your app supervision tree, with something like:
...
supervise(ExLimiter.Storage.PG2Shard.Supervisor, [])
Link to this section Summary
Functions
Consumes n elements from the bucket (atomically)
Callback implementation for ExLimiter.Storage.delete/1
Fetch the current state of the given bucket
Callback implementation for ExLimiter.Storage.refresh/2
Atomically update the bucket denoted by key
with fun
. Leverage whatever
concurrency controls are available in the given storage mechanism (eg cas for memcached)
Link to this section Functions
consume(bucket, incr) View Source
Consumes n elements from the bucket (atomically)
Callback implementation for ExLimiter.Storage.consume/2
.
delete(bucket) View Source
Callback implementation for ExLimiter.Storage.delete/1
.
fetch(bucket) View Source
Fetch the current state of the given bucket
Callback implementation for ExLimiter.Storage.fetch/1
.
leak_and_consume(bucket, update_fn, boundary_fn, incr) View Source
refresh(bucket, type \\ :soft) View Source
Callback implementation for ExLimiter.Storage.refresh/2
.
update(key, update_fun) View Source
Atomically update the bucket denoted by key
with fun
. Leverage whatever
concurrency controls are available in the given storage mechanism (eg cas for memcached)
Callback implementation for ExLimiter.Storage.update/2
.