1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00

Allows configuration of the Dead Job Queue.

This commit is contained in:
Jonathan Hyman 2015-02-04 15:33:49 -05:00
parent 32e1a414f1
commit b9c2982638
4 changed files with 19 additions and 8 deletions

View file

@ -1,3 +1,7 @@
3.3.2 (unreleased)
-----------
- Allows configuration of dead job set size and timeout
3.3.1 3.3.1
----------- -----------

View file

@ -25,7 +25,9 @@ module Sidekiq
startup: [], startup: [],
quiet: [], quiet: [],
shutdown: [], shutdown: [],
} },
dead_max_jobs: 10_000,
dead_timeout_in_seconds: 180 * 24 * 60 * 60 # 6 months
} }
def self.°° def self.°°

View file

@ -399,8 +399,8 @@ module Sidekiq
Sidekiq.redis do |conn| Sidekiq.redis do |conn|
conn.multi do conn.multi do
conn.zadd('dead', now, message) conn.zadd('dead', now, message)
conn.zremrangebyscore('dead', '-inf', now - DeadSet::TIMEOUT) conn.zremrangebyscore('dead', '-inf', now - DeadSet.timeout)
conn.zremrangebyrank('dead', 0, - DeadSet::MAX_JOBS) conn.zremrangebyrank('dead', 0, - DeadSet.max_jobs)
end end
end end
end end
@ -593,9 +593,6 @@ module Sidekiq
# Allows enumeration of dead jobs within Sidekiq. # Allows enumeration of dead jobs within Sidekiq.
# #
class DeadSet < JobSet class DeadSet < JobSet
TIMEOUT = 180 * 24 * 60 * 60 # 6 months
MAX_JOBS = 10_000
def initialize def initialize
super 'dead' super 'dead'
end end
@ -605,6 +602,14 @@ module Sidekiq
each(&:retry) each(&:retry)
end end
end end
def self.max_jobs
Sidekiq.options[:dead_max_jobs]
end
def self.timeout
Sidekiq.options[:dead_timeout_in_seconds]
end
end end
## ##

View file

@ -156,8 +156,8 @@ module Sidekiq
Sidekiq.redis do |conn| Sidekiq.redis do |conn|
conn.multi do conn.multi do
conn.zadd('dead', now, payload) conn.zadd('dead', now, payload)
conn.zremrangebyscore('dead', '-inf', now - DeadSet::TIMEOUT) conn.zremrangebyscore('dead', '-inf', now - DeadSet.timeout)
conn.zremrangebyrank('dead', 0, -DeadSet::MAX_JOBS) conn.zremrangebyrank('dead', 0, -DeadSet.max_jobs)
end end
end end
end end