class Cuetip::Job
Attributes
Return the queued job object
@return [Cuetip::Models::Job]
Public Class Methods
The length of time (in seconds) from when this job is queued to when it should be executed
# File lib/cuetip/job.rb, line 39 def delay_execution @delay_execution || 0 end
Should this job be deleted after execution
# File lib/cuetip/job.rb, line 45 def delete_after_execution @delete_after_execution || false end
The maximum length of time (in seconds) that a job can run for
# File lib/cuetip/job.rb, line 15 def maximum_execution_time @maximum_execution_time || 12.hours end
Initialize this job instance by providing a queued job instance
@param queued_job [Cuetip::Models::Job]
# File lib/cuetip/job.rb, line 84 def initialize(job) @job = job end
Prune jobs before a specific time
@param before [ActiveSupport::TimeWithZone] The point in time to prune jobs until.
# File lib/cuetip/job.rb, line 76 def prune(before) Models::Job.where('created_at < ?', before).delete_all end
Queue this job
@param params [Hash] @return [Cuetip::Models::Job]
# File lib/cuetip/job.rb, line 54 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 job.delete_after_execution = delete_after_execution # Call the block block.call(job) if block_given? # Create the job job.save! # Return the job job end
The queue that this job should be executed on
# File lib/cuetip/job.rb, line 9 def queue_name @queue_name || 'default' end
The maximum number of times this job can be run
# File lib/cuetip/job.rb, line 27 def retry_count @retry_count || 0 end
The maximum length of time (in seconds) between each execution of this job
# File lib/cuetip/job.rb, line 33 def retry_interval @retry_interval || 1.minute end
The maximum length of time (in seconds) between the job being created and it being run
# File lib/cuetip/job.rb, line 21 def ttl @ttl || 6.hours end
Public Instance Methods
Perform a job
@return [void]
# File lib/cuetip/job.rb, line 91 def perform; end
Private Instance Methods
Return a quick access for the job
@return [Logger]
# File lib/cuetip/job.rb, line 110 def logger Cuetip.logger end
Return all parameters for the job
@return [Hashie::Mash]
# File lib/cuetip/job.rb, line 98 def params @job.params end