Class: Qless::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.
388 389 390 391 392 393 394 395 396 397 398 399 |
# File 'lib/qless/job.rb', line 388 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.
386 387 388 |
# File 'lib/qless/job.rb', line 386 def backlog @backlog end |
#count ⇒ Object (readonly)
Returns the value of attribute count.
385 386 387 |
# File 'lib/qless/job.rb', line 385 def count @count end |
#data ⇒ Object
Returns the value of attribute data.
385 386 387 |
# File 'lib/qless/job.rb', line 385 def data @data end |
#interval ⇒ Object
Returns the value of attribute interval.
385 386 387 |
# File 'lib/qless/job.rb', line 385 def interval @interval end |
#jid ⇒ Object (readonly)
Returns the value of attribute jid.
385 386 387 |
# File 'lib/qless/job.rb', line 385 def jid @jid end |
#klass_name ⇒ Object (readonly)
Returns the value of attribute klass_name.
386 387 388 |
# File 'lib/qless/job.rb', line 386 def klass_name @klass_name end |
#priority ⇒ Object
Returns the value of attribute priority.
385 386 387 |
# File 'lib/qless/job.rb', line 385 def priority @priority end |
#queue_name ⇒ Object (readonly)
Returns the value of attribute queue_name.
386 387 388 |
# File 'lib/qless/job.rb', line 386 def queue_name @queue_name end |
#retries ⇒ Object
Returns the value of attribute retries.
385 386 387 |
# File 'lib/qless/job.rb', line 385 def retries @retries end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
385 386 387 |
# File 'lib/qless/job.rb', line 385 def @tags end |
Instance Method Details
#cancel ⇒ Object
437 438 439 |
# File 'lib/qless/job.rb', line 437 def cancel @client.call('unrecur', @jid) end |
#klass=(value) ⇒ Object
421 422 423 424 |
# File 'lib/qless/job.rb', line 421 def klass=(value) @client.call('recur.update', @jid, 'klass', value.to_s) @klass_name = value.to_s end |
#last_spawned_jid ⇒ Object
449 450 451 452 |
# File 'lib/qless/job.rb', line 449 def last_spawned_jid return nil if never_spawned? "#{jid}-#{count}" end |
#last_spawned_job ⇒ Object
454 455 456 457 |
# File 'lib/qless/job.rb', line 454 def last_spawned_job return nil if never_spawned? @client.jobs[last_spawned_jid] end |
#move(queue) ⇒ Object Also known as: requeue
431 432 433 434 |
# File 'lib/qless/job.rb', line 431 def move(queue) @client.call('recur.update', @jid, 'queue', queue) @queue_name = queue end |
#tag(*tags) ⇒ Object
441 442 443 |
# File 'lib/qless/job.rb', line 441 def tag(*) @client.call('recur.tag', @jid, *) end |
#untag(*tags) ⇒ Object
445 446 447 |
# File 'lib/qless/job.rb', line 445 def untag(*) @client.call('recur.untag', @jid, *) end |