Class: Sidekiq::DeadSet
Overview
The set of dead jobs within Sidekiq. Dead jobs have failed all of their retries and are helding in this set pending some sort of manual fix. They will be removed after 6 months (dead_timeout) if not.
Instance Attribute Summary
Attributes inherited from SortedSet
Instance Method Summary collapse
-
#initialize ⇒ DeadSet
constructor
A new instance of DeadSet.
-
#kill(message, opts = {}) ⇒ Object
Add the given job to the Dead set.
-
#retry_all ⇒ Object
Enqueue all dead jobs.
Methods inherited from JobSet
#delete_by_jid, #delete_by_value, #each, #fetch, #find_job, #schedule
Methods inherited from SortedSet
#as_json, #clear, #scan, #size
Constructor Details
#initialize ⇒ DeadSet
Returns a new instance of DeadSet.
810 811 812 |
# File 'lib/sidekiq/api.rb', line 810 def initialize super("dead") end |
Instance Method Details
#kill(message, opts = {}) ⇒ Object
Add the given job to the Dead set.
816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 |
# File 'lib/sidekiq/api.rb', line 816 def kill(, opts = {}) now = Time.now.to_f Sidekiq.redis do |conn| conn.multi do |transaction| transaction.zadd(name, now.to_s, ) transaction.zremrangebyscore(name, "-inf", now - Sidekiq::Config::DEFAULTS[:dead_timeout_in_seconds]) transaction.zremrangebyrank(name, 0, - Sidekiq::Config::DEFAULTS[:dead_max_jobs]) end end if opts[:notify_failure] != false job = Sidekiq.load_json() r = RuntimeError.new("Job killed by API") r.set_backtrace(caller) Sidekiq.default_configuration.death_handlers.each do |handle| handle.call(job, r) end end true end |
#retry_all ⇒ Object
Enqueue all dead jobs
838 839 840 |
# File 'lib/sidekiq/api.rb', line 838 def retry_all each(&:retry) while size > 0 end |