class Sidekiq::DeadSet
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.
Public Class Methods
Source
# File lib/sidekiq/api.rb, line 879 def initialize super("dead") end
Calls superclass method
Public Instance Methods
Source
# File lib/sidekiq/api.rb, line 900 def kill(message, opts = {}) now = Time.now.to_f Sidekiq.redis do |conn| conn.zadd(name, now.to_s, message) end trim if opts[:trim] != false if opts[:notify_failure] != false job = Sidekiq.load_json(message) 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
Add the given job to the Dead set. @param message [String] the job data as JSON @option opts [Boolean] :notify_failure (true) Whether death handlers should be called @option opts [Boolean] :trim (true) Whether Sidekiq
should trim the structure to keep it within configuration @option opts [Exception] :ex (RuntimeError) An exception to pass to the death handlers
Source
# 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
Trim dead jobs which are over our storage limits