ExqLimit v0.1.3 ExqLimit.And View Source

This module provides the ability to combine multiple rate limiters together.

{ExqLimit.And,
  [
    {ExqLimit.Local, limit: 20},
    {ExqLimit.Global, limit: 100},
    {ExqLimit.GCRA, [period: :second, rate: 60, burst: 0], short_circuit: true}
  ]
}

The above example creates a rate limiter which dequeues new jobs only if all the rate limiters return true. This can be used to create interesting combinations and also supports custom rate limiters as long as it implements the Exq.Dequeue.Behaviour behaviour

Options

  • short_circuit (boolean) - whether to short circuit the Exq.Dequeue.Behaviour.available?/1 call when any one of the previous rate limiters returned false. Defaults to false.

Some of the modules in ExqLimit expect specific value to be set for short_circuit option, otherwise the behaviour is undefined when used with ExqLimit.And. Order is also important, those with short_circuit: true should be placed last.

moduleshort_circuit
ExqLimit.Localtrue or false
ExqLimit.Globalfalse
ExqLimit.GCRAtrue