ex_limiter v1.3.5 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

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

Consumes n elements from the bucket (atomically)

Callback implementation for ExLimiter.Storage.consume/2.

Callback implementation for ExLimiter.Storage.delete/1.

Fetch the current state of the given bucket

Callback implementation for ExLimiter.Storage.fetch/1.

Link to this function

leak_and_consume(bucket, update_fn, boundary_fn, incr) View Source

Link to this function

refresh(bucket, type \\ :soft) View Source

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)

Callback implementation for ExLimiter.Storage.update/2.