Class: Sidekiq::SortedEntry
- Inherits:
-
Job
- Object
- Job
- Sidekiq::SortedEntry
show all
- Defined in:
- lib/sidekiq/api.rb
Instance Attribute Summary collapse
Attributes inherited from Job
#item, #queue, #value
Instance Method Summary
collapse
Methods inherited from Job
#[], #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.
450
451
452
453
454
|
# File 'lib/sidekiq/api.rb', line 450
def initialize(parent, score, item)
super(item)
@score = score
@parent = parent
end
|
Instance Attribute Details
#parent ⇒ Object
Returns the value of attribute parent.
448
449
450
|
# File 'lib/sidekiq/api.rb', line 448
def parent
@parent
end
|
#score ⇒ Object
Returns the value of attribute score.
447
448
449
|
# File 'lib/sidekiq/api.rb', line 447
def score
@score
end
|
Instance Method Details
#add_to_queue ⇒ Object
474
475
476
477
478
479
|
# File 'lib/sidekiq/api.rb', line 474
def add_to_queue
remove_job do |message|
msg = Sidekiq.load_json(message)
Sidekiq::Client.push(msg)
end
end
|
#at ⇒ Object
456
457
458
|
# File 'lib/sidekiq/api.rb', line 456
def at
Time.at(score).utc
end
|
#delete ⇒ Object
460
461
462
463
464
465
466
|
# File 'lib/sidekiq/api.rb', line 460
def delete
if @value
@parent.delete_by_value(@parent.name, @value)
else
@parent.delete_by_jid(score, jid)
end
end
|
#error? ⇒ Boolean
497
498
499
|
# File 'lib/sidekiq/api.rb', line 497
def error?
!!item["error_class"]
end
|
#kill ⇒ Object
Place job in the dead set
491
492
493
494
495
|
# File 'lib/sidekiq/api.rb', line 491
def kill
remove_job do |message|
DeadSet.new.kill(message)
end
end
|
#reschedule(at) ⇒ Object
468
469
470
471
472
|
# File 'lib/sidekiq/api.rb', line 468
def reschedule(at)
Sidekiq.redis do |conn|
conn.zincrby(@parent.name, at.to_f - @score, Sidekiq.dump_json(@item))
end
end
|
#retry ⇒ Object
481
482
483
484
485
486
487
|
# File 'lib/sidekiq/api.rb', line 481
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
|