Skip to content

wli0503/exq_throttler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ExqThrottler

A throttler implementation for Exq.

  • WORK IN PROGRESS. *

Installation

If available in Hex, the package can be installed as:

  1. Add exq_throttler to your list of dependencies in mix.exs:

    def deps do [{:exq_throttler, "~> 0.0.1"}] end

Usage

  1. Add Exq.Middleware.Throttler to your config/*.exs:
# in config/dev.exs
config :exq,
# Note here that Exq.Middleware.Job must exist before Exq.Middleware.Throttler since
# Throttler requires information from Job
middleware: [Exq.Middleware.Job, Exq.Middleware.Throttler, <other middlewares>]
  1. Add configurations for Exq.Middlware.Throttler in config/*.exs:
# in config/dev.exs
config :exq,
  throttler: [
    <queue_name>: [
      period: 60,        
      threshold: 3,    
      delay: 60
    ]
  ]

period and threshold in combine determines when it should throttle. Throttler will check the number of jobs in the period, then delay others according to the delay set in the configuration. Note that it's recommended to have delay >= period.

About

Throttler middleware for Exq

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages