Class: Sidekiq::SortedEntry
Instance Attribute Summary collapse
Attributes inherited from JobRecord
#item, #queue, #value
Instance Method Summary
collapse
Methods inherited from JobRecord
#[], #args, #created_at, #display_args, #display_class, #enqueued_at, #error_backtrace, #jid, #klass, #latency, #parse, #tags
Constructor Details
#initialize(parent, score, item) ⇒ SortedEntry
Returns a new instance of SortedEntry.
467
468
469
470
471
|
# File 'lib/sidekiq/api.rb', line 467
def initialize(parent, score, item)
super(item)
@score = score
@parent = parent
end
|
Instance Attribute Details
#parent ⇒ Object
Returns the value of attribute parent.
465
466
467
|
# File 'lib/sidekiq/api.rb', line 465
def parent
@parent
end
|
#score ⇒ Object
Returns the value of attribute score.
464
465
466
|
# File 'lib/sidekiq/api.rb', line 464
def score
@score
end
|
Instance Method Details
#add_to_queue ⇒ Object
491
492
493
494
495
496
|
# File 'lib/sidekiq/api.rb', line 491
def add_to_queue
remove_job do |message|
msg = Sidekiq.load_json(message)
Sidekiq::Client.push(msg)
end
end
|
#at ⇒ Object
473
474
475
|
# File 'lib/sidekiq/api.rb', line 473
def at
Time.at(score).utc
end
|
#delete ⇒ Object
477
478
479
480
481
482
483
|
# File 'lib/sidekiq/api.rb', line 477
def delete
if @value
@parent.delete_by_value(@parent.name, @value)
else
@parent.delete_by_jid(score, jid)
end
end
|
#error? ⇒ Boolean
514
515
516
|
# File 'lib/sidekiq/api.rb', line 514
def error?
!!item["error_class"]
end
|
#kill ⇒ Object
Place job in the dead set
508
509
510
511
512
|
# File 'lib/sidekiq/api.rb', line 508
def kill
remove_job do |message|
DeadSet.new.kill(message)
end
end
|
#reschedule(at) ⇒ Object
485
486
487
488
489
|
# File 'lib/sidekiq/api.rb', line 485
def reschedule(at)
Sidekiq.redis do |conn|
conn.zincrby(@parent.name, at.to_f - @score, Sidekiq.dump_json(@item))
end
end
|
#retry ⇒ Object
498
499
500
501
502
503
504
|
# File 'lib/sidekiq/api.rb', line 498
def retry
remove_job do |message|
msg = Sidekiq.load_json(message)
msg["retry_count"] -= 1 if msg["retry_count"]
Sidekiq::Client.push(msg)
end
end
|