Exq.Dequeue.Behaviour behaviour (exq v0.15.0) View Source

Custom concurrency or rate limiting at a queue level can be achieved by implementing the Dequeue behaviour.

The following config can be used to customize dequeue behaviour for a queue:

config :exq,
  queues: [{"default", {RateLimiter, options}}]

RateLimiter module should implement Exq.Dequeue.Behaviour. The options supplied here would be passed as the second argument to the init/2 function.

Life cycle

init/2 will be invoked on initialization. The first argument will contain info like queue and the second argument is user configurable.

available?/1 will be invoked before each poll. If the returned value contains false as the second element of the tuple, the queue will not polled

dispatched/1 will be invoked once a job is dispatched to the worker

processed/1 will be invoked if a job completed successfully

failed/1 will be invoked if a job failed

stop/1 will be invoked when a queue is unsubscribed or before the node terminates. Note: there is no guarantee this will be invoked if the node terminates abruptly

Link to this section Summary

Link to this section Callbacks


available?(state :: term()) :: {:ok, boolean(), term()}


dispatched(state :: term()) :: {:ok, term()}


failed(state :: term()) :: {:ok, term()}


init(info :: %{queue: String.t()}, args :: term()) :: {:ok, term()}


processed(state :: term()) :: {:ok, term()}


stop(state :: term()) :: :ok