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.
-
#trim ⇒ Object
Trim dead jobs which are over our storage limits.
Methods inherited from JobSet
#each, #fetch, #find_job, #kill_all, #pop_each, #retry_all, #schedule
Methods inherited from SortedSet
Constructor Details
#initialize ⇒ DeadSet
Returns a new instance of DeadSet.
879 880 881 |
# File 'lib/sidekiq/api.rb', line 879 def initialize super("dead") end |
Instance Method Details
#kill(message, opts = {}) ⇒ Object
Add the given job to the Dead set.
900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 |
# File 'lib/sidekiq/api.rb', line 900 def kill(, opts = {}) now = Time.now.to_f Sidekiq.redis do |conn| conn.zadd(name, now.to_s, ) end trim if opts[:trim] != false if opts[:notify_failure] != false job = Sidekiq.load_json() if opts[:ex] ex = opts[:ex] else ex = RuntimeError.new("Job killed by API") ex.set_backtrace(caller) end Sidekiq.default_configuration.death_handlers.each do |handle| handle.call(job, ex) end end true end |
#trim ⇒ Object
Trim dead jobs which are over our storage limits
884 885 886 887 888 889 890 891 892 893 |
# File 'lib/sidekiq/api.rb', line 884 def trim hash = Sidekiq.default_configuration now = Time.now.to_f Sidekiq.redis do |conn| conn.multi do |transaction| transaction.zremrangebyscore(name, "-inf", now - hash[:dead_timeout_in_seconds]) transaction.zremrangebyrank(name, 0, - hash[:dead_max_jobs]) end end end |