Class: Sidekiq::DeadSet
Overview
Allows enumeration of dead jobs within Sidekiq.
Instance Attribute Summary
Attributes inherited from SortedSet
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ DeadSet
constructor
A new instance of DeadSet.
- #kill(message, opts = {}) ⇒ Object
- #retry_all ⇒ Object
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.
740 741 742 |
# File 'lib/sidekiq/api.rb', line 740 def initialize super "dead" end |
Class Method Details
.max_jobs ⇒ Object
769 770 771 |
# File 'lib/sidekiq/api.rb', line 769 def self.max_jobs Sidekiq[:dead_max_jobs] end |
.timeout ⇒ Object
773 774 775 |
# File 'lib/sidekiq/api.rb', line 773 def self.timeout Sidekiq[:dead_timeout_in_seconds] end |
Instance Method Details
#kill(message, opts = {}) ⇒ Object
744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 |
# File 'lib/sidekiq/api.rb', line 744 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 - self.class.timeout) transaction.zremrangebyrank(name, 0, - self.class.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.death_handlers.each do |handle| handle.call(job, r) end end true end |
#retry_all ⇒ Object
765 766 767 |
# File 'lib/sidekiq/api.rb', line 765 def retry_all each(&:retry) while size > 0 end |