Class: Sidekiq::SortedEntry

Inherits:
Job
  • Object
show all
Defined in:
lib/sidekiq/api.rb

Constant Summary

Constants inherited from Job

Job::KNOWN_WRAPPERS

Instance Attribute Summary collapse

Attributes inherited from Job

#item

Instance Method Summary collapse

Methods inherited from Job

#[], #args, #display_args, #display_class, #enqueued_at, #jid, #klass, #latency, #queue

Constructor Details

#initialize(parent, score, item) ⇒ SortedEntry

Returns a new instance of SortedEntry.



284
285
286
287
288
# File 'lib/sidekiq/api.rb', line 284

def initialize(parent, score, item)
  super(item)
  @score = score
  @parent = parent
end

Instance Attribute Details

#parentObject (readonly)

Returns the value of attribute parent.



282
283
284
# File 'lib/sidekiq/api.rb', line 282

def parent
  @parent
end

#scoreObject (readonly)

Returns the value of attribute score.



281
282
283
# File 'lib/sidekiq/api.rb', line 281

def score
  @score
end

Instance Method Details

#add_to_queueObject



303
304
305
306
307
308
# File 'lib/sidekiq/api.rb', line 303

def add_to_queue
  remove_job do |message|
    msg = Sidekiq.load_json(message)
    Sidekiq::Client.push(msg)
  end
end

#atObject



290
291
292
# File 'lib/sidekiq/api.rb', line 290

def at
  Time.at(score).utc
end

#deleteObject



294
295
296
# File 'lib/sidekiq/api.rb', line 294

def delete
  @parent.delete(score, jid)
end

#reschedule(at) ⇒ Object



298
299
300
301
# File 'lib/sidekiq/api.rb', line 298

def reschedule(at)
  @parent.delete(score, jid)
  @parent.schedule(at, item)
end

#retryObject



310
311
312
313
314
315
316
317
# File 'lib/sidekiq/api.rb', line 310

def retry
  raise "Retry not available on jobs which have not failed" unless item["failed_at"]
  remove_job do |message|
    msg = Sidekiq.load_json(message)
    msg['retry_count'] = msg['retry_count'] - 1
    Sidekiq::Client.push(msg)
  end
end