class Sidekiq::Undertaker::DeadJob

Attributes

bucket_name[RW]
error_class[RW]
job[RW]
job_class[RW]
time_elapsed_since_failure[RW]

Public Class Methods

for_each() { |to_dead_job(job)| ... } click to toggle source
# File lib/sidekiq/undertaker/dead_job.rb, line 9
def for_each
  Sidekiq::DeadSet.new.each do |job|
    yield to_dead_job(job)
  end
end
new(args) click to toggle source
# File lib/sidekiq/undertaker/dead_job.rb, line 32
def initialize(args)
  @job                        = args.fetch(:job)
  @time_elapsed_since_failure = args.fetch(:time_elapsed_since_failure)
  @bucket_name                = args.fetch(:bucket_name)
  @job_class                  = args.fetch(:job_class, job.item["class"])
  @error_class                = args.fetch(:error_class, job.item["error_class"])
end
parsed_failed_at(job) click to toggle source
# File lib/sidekiq/undertaker/dead_job.rb, line 25
def parsed_failed_at(job)
  job.item["failed_at"].is_a?(String) ? Time.parse(job.item["failed_at"]) : job.item["failed_at"]
end
to_dead_job(job) click to toggle source
# File lib/sidekiq/undertaker/dead_job.rb, line 15
def to_dead_job(job)
  job_failed_at                  = parsed_failed_at(job)
  job_time_elapsed_since_failure = Time.now.to_i - job_failed_at.to_i
  job_bucket_name                = Bucket.for_elapsed_time(job_time_elapsed_since_failure)

  new(job:                        job,
      time_elapsed_since_failure: job_time_elapsed_since_failure,
      bucket_name:                job_bucket_name)
end

Public Instance Methods

==(other) click to toggle source
# File lib/sidekiq/undertaker/dead_job.rb, line 40
def ==(other)
  job_class == other.job_class &&
    time_elapsed_since_failure == other.time_elapsed_since_failure &&
    error_class                == other.error_class &&
    bucket_name                == other.bucket_name &&
    job_eql?(other.job)
end
Also aliased as: eql?
eql?(other)
Alias for: ==

Private Instance Methods

job_eql?(other_job) click to toggle source
# File lib/sidekiq/undertaker/dead_job.rb, line 53
def job_eql?(other_job) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
  job.jid == other_job.jid &&
    job.item        == other_job.item &&
    job.args        == other_job.args &&
    job.queue       == other_job.queue &&
    job.score       == other_job.score &&
    job.parent.name == other_job.parent.name &&
    job.parent.size == other_job.parent.size
end