Class: Cuetip::Job
- Inherits:
-
Object
- Object
- Cuetip::Job
- Defined in:
- lib/cuetip/job.rb
Class Attribute Summary collapse
-
.delay_execution ⇒ Object
The length of time (in seconds) from when this job is queued to when it should be executed.
-
.maximum_execution_time ⇒ Object
The maximum length of time (in seconds) that a job can run for.
-
.queue_name ⇒ Object
The queue that this job should be executed on.
-
.retry_count ⇒ Object
The maximum number of times this job can be run.
-
.retry_interval ⇒ Object
The maximum length of time (in seconds) between each execution of this job.
-
.ttl ⇒ Object
The maximum length of time (in seconds) between the job being created and it being run.
Class Method Summary collapse
-
.queue(params = {}, &block) ⇒ Cuetip::Models::Job
Queue this job.
Instance Method Summary collapse
-
#initialize(job) ⇒ Job
constructor
Initialize this job instance by providing a queued job instance.
-
#perform ⇒ void
Perform a job.
Constructor Details
#initialize(job) ⇒ Job
Initialize this job instance by providing a queued job instance
70 71 72 |
# File 'lib/cuetip/job.rb', line 70 def initialize(job) @job = job end |
Class Attribute Details
.delay_execution ⇒ Object
The length of time (in seconds) from when this job is queued to when it should be executed
39 40 41 |
# File 'lib/cuetip/job.rb', line 39 def delay_execution @delay_execution || 0 end |
.maximum_execution_time ⇒ Object
The maximum length of time (in seconds) that a job can run for
15 16 17 |
# File 'lib/cuetip/job.rb', line 15 def maximum_execution_time @maximum_execution_time || 12.hours end |
.queue_name ⇒ Object
The queue that this job should be executed on
9 10 11 |
# File 'lib/cuetip/job.rb', line 9 def queue_name @queue_name || 'default' end |
.retry_count ⇒ Object
The maximum number of times this job can be run
27 28 29 |
# File 'lib/cuetip/job.rb', line 27 def retry_count @retry_count || 0 end |
.retry_interval ⇒ Object
The maximum length of time (in seconds) between each execution of this job
33 34 35 |
# File 'lib/cuetip/job.rb', line 33 def retry_interval @retry_interval || 1.minute end |
.ttl ⇒ Object
The maximum length of time (in seconds) between the job being created and it being run
21 22 23 |
# File 'lib/cuetip/job.rb', line 21 def ttl @ttl || 6.hours end |
Class Method Details
.queue(params = {}, &block) ⇒ Cuetip::Models::Job
Queue this job
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/cuetip/job.rb', line 48 def queue(params = {}, &block) # Create our new job job = Models::Job.new(class_name: name, params: params) # Copy over any class leve lconfig job.queue_name = queue_name job.maximum_execution_time = maximum_execution_time job.ttl = ttl job.retry_count = retry_count job.retry_interval = retry_interval job.delay_execution = delay_execution # Call the block block.call(job) if block_given? # Create the job job.save! # Return the job job end |
Instance Method Details
#perform ⇒ void
This method returns an undefined value.
Perform a job
77 |
# File 'lib/cuetip/job.rb', line 77 def perform; end |