Class: Roundhouse::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
-
#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_id
Constructor Details
#initialize(parent, score, item) ⇒ SortedEntry
Returns a new instance of SortedEntry.
413 414 415 416 417 |
# File 'lib/roundhouse/api.rb', line 413 def initialize(parent, score, item) super(item) @score = score @parent = parent end |
Instance Attribute Details
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
411 412 413 |
# File 'lib/roundhouse/api.rb', line 411 def parent @parent end |
#score ⇒ Object (readonly)
Returns the value of attribute score.
410 411 412 |
# File 'lib/roundhouse/api.rb', line 410 def score @score end |
Instance Method Details
#add_to_queue ⇒ Object
436 437 438 439 440 441 |
# File 'lib/roundhouse/api.rb', line 436 def add_to_queue remove_job do || msg = Roundhouse.load_json() Roundhouse::Client.push(msg) end end |
#at ⇒ Object
419 420 421 |
# File 'lib/roundhouse/api.rb', line 419 def at Time.at(score).utc end |
#delete ⇒ Object
423 424 425 426 427 428 429 |
# File 'lib/roundhouse/api.rb', line 423 def delete if @value @parent.delete_by_value(@parent.name, @value) else @parent.delete_by_jid(score, jid) end end |
#kill ⇒ Object
Place job in the dead set
454 455 456 457 458 459 460 461 462 463 464 465 466 467 |
# File 'lib/roundhouse/api.rb', line 454 def kill raise 'Kill not available on jobs which have not failed' unless item['failed_at'] remove_job do || Roundhouse.logger.info { "Killing job #{['jid']}" } now = Time.now.to_f Roundhouse.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
431 432 433 434 |
# File 'lib/roundhouse/api.rb', line 431 def reschedule(at) delete @parent.schedule(at, item) end |
#retry ⇒ Object
443 444 445 446 447 448 449 450 |
# File 'lib/roundhouse/api.rb', line 443 def retry raise "Retry not available on jobs which have not failed" unless item["failed_at"] remove_job do || msg = Roundhouse.load_json() msg['retry_count'] -= 1 Roundhouse::Client.push(msg) end end |