Class: Cuetip::Job

Inherits:
Object
  • Object
show all
Defined in:
lib/cuetip/job.rb

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(job) ⇒ Job

Initialize this job instance by providing a queued job instance

Parameters:



70
71
72
# File 'lib/cuetip/job.rb', line 70

def initialize(job)
  @job = job
end

Class Attribute Details

.delay_executionObject

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_timeObject

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_nameObject

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_countObject

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_intervalObject

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

.ttlObject

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

Parameters:

  • params (Hash) (defaults to: {})

Returns:



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

#performvoid

This method returns an undefined value.

Perform a job



77
# File 'lib/cuetip/job.rb', line 77

def perform; end