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, #value
Instance Method Summary
collapse
Methods inherited from Job
#[], #args, #created_at, #display_args, #display_class, #enqueued_at, #jid, #klass, #latency, #parse, #queue
Constructor Details
#initialize(parent, score, item) ⇒ SortedEntry
Returns a new instance of SortedEntry.
414
415
416
417
418
|
# File 'lib/sidekiq/api.rb', line 414
def initialize(parent, score, item)
super(item)
@score = score
@parent = parent
end
|
Instance Attribute Details
#parent ⇒ Object
Returns the value of attribute parent.
412
413
414
|
# File 'lib/sidekiq/api.rb', line 412
def parent
@parent
end
|
#score ⇒ Object
Returns the value of attribute score.
411
412
413
|
# File 'lib/sidekiq/api.rb', line 411
def score
@score
end
|
Instance Method Details
#add_to_queue ⇒ Object
437
438
439
440
441
442
|
# File 'lib/sidekiq/api.rb', line 437
def add_to_queue
remove_job do |message|
msg = Sidekiq.load_json(message)
Sidekiq::Client.push(msg)
end
end
|
#at ⇒ Object
420
421
422
|
# File 'lib/sidekiq/api.rb', line 420
def at
Time.at(score).utc
end
|
#delete ⇒ Object
424
425
426
427
428
429
430
|
# File 'lib/sidekiq/api.rb', line 424
def delete
if @value
@parent.delete_by_value(@parent.name, @value)
else
@parent.delete_by_jid(score, jid)
end
end
|
#error? ⇒ Boolean
467
468
469
|
# File 'lib/sidekiq/api.rb', line 467
def error?
!!item['error_class']
end
|
#kill ⇒ Object
Place job in the dead set
454
455
456
457
458
459
460
461
462
463
464
465
|
# File 'lib/sidekiq/api.rb', line 454
def kill
remove_job do |message|
now = Time.now.to_f
Sidekiq.redis do |conn|
conn.multi do
conn.zadd('dead', now, message)
conn.zremrangebyscore('dead', '-inf', now - DeadSet.timeout)
conn.zremrangebyrank('dead', 0, - DeadSet.max_jobs)
end
end
end
end
|
#reschedule(at) ⇒ Object
432
433
434
435
|
# File 'lib/sidekiq/api.rb', line 432
def reschedule(at)
delete
@parent.schedule(at, item)
end
|
#retry ⇒ Object
444
445
446
447
448
449
450
|
# File 'lib/sidekiq/api.rb', line 444
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
|