Class: Sidekiq::SortedEntry
Instance Attribute Summary collapse
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#score ⇒ Object
readonly
Returns the value of attribute score.
Attributes inherited from Job
Instance Method Summary collapse
- #add_to_queue ⇒ Object
- #at ⇒ Object
- #delete ⇒ Object
- #error? ⇒ Boolean
-
#initialize(parent, score, item) ⇒ SortedEntry
constructor
A new instance of SortedEntry.
-
#kill ⇒ Object
Place job in the dead set.
- #reschedule(at) ⇒ Object
- #retry ⇒ Object
Methods inherited from Job
#[], #args, #created_at, #display_args, #display_class, #enqueued_at, #jid, #klass, #latency, #queue
Constructor Details
#initialize(parent, score, item) ⇒ SortedEntry
Returns a new instance of SortedEntry.
395 396 397 398 399 |
# File 'lib/sidekiq/api.rb', line 395 def initialize(parent, score, item) super(item) @score = score @parent = parent end |
Instance Attribute Details
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
393 394 395 |
# File 'lib/sidekiq/api.rb', line 393 def parent @parent end |
#score ⇒ Object (readonly)
Returns the value of attribute score.
392 393 394 |
# File 'lib/sidekiq/api.rb', line 392 def score @score end |
Instance Method Details
#add_to_queue ⇒ Object
418 419 420 421 422 423 |
# File 'lib/sidekiq/api.rb', line 418 def add_to_queue remove_job do || msg = Sidekiq.load_json() Sidekiq::Client.push(msg) end end |
#at ⇒ Object
401 402 403 |
# File 'lib/sidekiq/api.rb', line 401 def at Time.at(score).utc end |
#delete ⇒ Object
405 406 407 408 409 410 411 |
# File 'lib/sidekiq/api.rb', line 405 def delete if @value @parent.delete_by_value(@parent.name, @value) else @parent.delete_by_jid(score, jid) end end |
#error? ⇒ Boolean
448 449 450 |
# File 'lib/sidekiq/api.rb', line 448 def error? !!item['error_class'] end |
#kill ⇒ Object
Place job in the dead set
435 436 437 438 439 440 441 442 443 444 445 446 |
# File 'lib/sidekiq/api.rb', line 435 def kill remove_job do || now = Time.now.to_f Sidekiq.redis do |conn| conn.multi do conn.zadd('dead', now, ) conn.zremrangebyscore('dead', '-inf', now - DeadSet.timeout) conn.zremrangebyrank('dead', 0, - DeadSet.max_jobs) end end end end |
#reschedule(at) ⇒ Object
413 414 415 416 |
# File 'lib/sidekiq/api.rb', line 413 def reschedule(at) delete @parent.schedule(at, item) end |