Class: Reqless::RecurringJob
Overview
Wraps a recurring job
Instance Attribute Summary collapse
-
#backlog ⇒ Object
Returns the value of attribute backlog.
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#data ⇒ Object
Returns the value of attribute data.
-
#interval ⇒ Object
Returns the value of attribute interval.
-
#jid ⇒ Object
readonly
Returns the value of attribute jid.
-
#klass_name ⇒ Object
readonly
Returns the value of attribute klass_name.
-
#priority ⇒ Object
Returns the value of attribute priority.
-
#queue_name ⇒ Object
readonly
Returns the value of attribute queue_name.
-
#retries ⇒ Object
Returns the value of attribute retries.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
Attributes inherited from BaseJob
Instance Method Summary collapse
- #cancel ⇒ Object
-
#initialize(client, atts) ⇒ RecurringJob
constructor
A new instance of RecurringJob.
- #klass=(value) ⇒ Object
- #last_spawned_jid ⇒ Object
- #last_spawned_job ⇒ Object
- #move(queue) ⇒ Object (also: #requeue)
- #tag(*tags) ⇒ Object
- #untag(*tags) ⇒ Object
Methods inherited from BaseJob
Constructor Details
#initialize(client, atts) ⇒ RecurringJob
Returns a new instance of RecurringJob.
419 420 421 422 423 424 425 426 427 428 429 430 |
# File 'lib/reqless/job.rb', line 419 def initialize(client, atts) super(client, atts.fetch('jid')) %w{jid data priority tags retries interval count backlog}.each do |att| instance_variable_set("@#{att}".to_sym, atts.fetch(att)) end # Parse the data string @data = JSON.parse(@data) @klass_name = atts.fetch('klass') @queue_name = atts.fetch('queue') @tags = [] if @tags == {} end |
Instance Attribute Details
#backlog ⇒ Object
Returns the value of attribute backlog.
417 418 419 |
# File 'lib/reqless/job.rb', line 417 def backlog @backlog end |
#count ⇒ Object (readonly)
Returns the value of attribute count.
416 417 418 |
# File 'lib/reqless/job.rb', line 416 def count @count end |
#data ⇒ Object
Returns the value of attribute data.
416 417 418 |
# File 'lib/reqless/job.rb', line 416 def data @data end |
#interval ⇒ Object
Returns the value of attribute interval.
416 417 418 |
# File 'lib/reqless/job.rb', line 416 def interval @interval end |
#jid ⇒ Object (readonly)
Returns the value of attribute jid.
416 417 418 |
# File 'lib/reqless/job.rb', line 416 def jid @jid end |
#klass_name ⇒ Object (readonly)
Returns the value of attribute klass_name.
417 418 419 |
# File 'lib/reqless/job.rb', line 417 def klass_name @klass_name end |
#priority ⇒ Object
Returns the value of attribute priority.
416 417 418 |
# File 'lib/reqless/job.rb', line 416 def priority @priority end |
#queue_name ⇒ Object (readonly)
Returns the value of attribute queue_name.
417 418 419 |
# File 'lib/reqless/job.rb', line 417 def queue_name @queue_name end |
#retries ⇒ Object
Returns the value of attribute retries.
416 417 418 |
# File 'lib/reqless/job.rb', line 416 def retries @retries end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
416 417 418 |
# File 'lib/reqless/job.rb', line 416 def @tags end |
Instance Method Details
#cancel ⇒ Object
468 469 470 |
# File 'lib/reqless/job.rb', line 468 def cancel @client.call('recurringJob.cancel', @jid) end |
#klass=(value) ⇒ Object
452 453 454 455 |
# File 'lib/reqless/job.rb', line 452 def klass=(value) @client.call('recurringJob.update', @jid, 'klass', value.to_s) @klass_name = value.to_s end |
#last_spawned_jid ⇒ Object
480 481 482 483 |
# File 'lib/reqless/job.rb', line 480 def last_spawned_jid return nil if never_spawned? "#{jid}-#{count}" end |
#last_spawned_job ⇒ Object
485 486 487 488 |
# File 'lib/reqless/job.rb', line 485 def last_spawned_job return nil if never_spawned? @client.jobs[last_spawned_jid] end |
#move(queue) ⇒ Object Also known as: requeue
462 463 464 465 |
# File 'lib/reqless/job.rb', line 462 def move(queue) @client.call('recurringJob.update', @jid, 'queue', queue) @queue_name = queue end |
#tag(*tags) ⇒ Object
472 473 474 |
# File 'lib/reqless/job.rb', line 472 def tag(*) @client.call('recurringJob.addTag', @jid, *) end |
#untag(*tags) ⇒ Object
476 477 478 |
# File 'lib/reqless/job.rb', line 476 def untag(*) @client.call('recurringJob.removeTag', @jid, *) end |