Class: Sidekiq::Undertaker::DeadJob
- Inherits:
-
Object
- Object
- Sidekiq::Undertaker::DeadJob
- Defined in:
- lib/sidekiq/undertaker/dead_job.rb
Instance Attribute Summary collapse
-
#bucket_name ⇒ Object
readonly
Returns the value of attribute bucket_name.
-
#error_class ⇒ Object
readonly
Returns the value of attribute error_class.
-
#error_msg ⇒ Object
readonly
Returns the value of attribute error_msg.
-
#job ⇒ Object
readonly
Returns the value of attribute job.
-
#job_class ⇒ Object
readonly
Returns the value of attribute job_class.
-
#time_elapsed_since_failure ⇒ Object
readonly
Returns the value of attribute time_elapsed_since_failure.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
-
#initialize(args) ⇒ DeadJob
constructor
A new instance of DeadJob.
Constructor Details
#initialize(args) ⇒ DeadJob
Returns a new instance of DeadJob.
32 33 34 35 36 37 38 39 |
# 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"]) @error_msg = shorten_error_msg(args.fetch(:error_message, job.item["error_message"]).to_s) end |
Instance Attribute Details
#bucket_name ⇒ Object
Returns the value of attribute bucket_name.
30 31 32 |
# File 'lib/sidekiq/undertaker/dead_job.rb', line 30 def bucket_name @bucket_name end |
#error_class ⇒ Object
Returns the value of attribute error_class.
30 31 32 |
# File 'lib/sidekiq/undertaker/dead_job.rb', line 30 def error_class @error_class end |
#error_msg ⇒ Object (readonly)
Returns the value of attribute error_msg.
30 31 32 |
# File 'lib/sidekiq/undertaker/dead_job.rb', line 30 def error_msg @error_msg end |
#job ⇒ Object
Returns the value of attribute job.
30 31 32 |
# File 'lib/sidekiq/undertaker/dead_job.rb', line 30 def job @job end |
#job_class ⇒ Object
Returns the value of attribute job_class.
30 31 32 |
# File 'lib/sidekiq/undertaker/dead_job.rb', line 30 def job_class @job_class end |
#time_elapsed_since_failure ⇒ Object
Returns the value of attribute time_elapsed_since_failure.
30 31 32 |
# File 'lib/sidekiq/undertaker/dead_job.rb', line 30 def time_elapsed_since_failure @time_elapsed_since_failure end |
Class Method Details
.for_each ⇒ Object
9 10 11 12 13 |
# 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 |
.parsed_failed_at(job) ⇒ Object
25 26 27 |
# 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) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# 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:, time_elapsed_since_failure: job_time_elapsed_since_failure, bucket_name: job_bucket_name) end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
41 42 43 44 45 46 47 48 |
# File 'lib/sidekiq/undertaker/dead_job.rb', line 41 def ==(other) job_class == other.job_class && time_elapsed_since_failure == other.time_elapsed_since_failure && error_class == other.error_class && error_msg == other.error_msg && bucket_name == other.bucket_name && job_eql?(other.job) end |