Parent

Resque::JobWithStatus

Public Class Methods

enqueue(klass, options = {}) click to toggle source

Adds a job of type <tt>klass<tt> to the queue with <tt>options<tt>. Returns the UUID of the job override to pass actual parameters instead of a single hash, to make backward compatible with existing resque jobs.

# File lib/resque_ui/overrides/resque_status/job_with_status.rb, line 6
def self.enqueue(klass, options = {})
  uuid = Resque::Status.create :name => "#{self.name}: #{options.inspect}"
  Resque.enqueue(klass, uuid, options)
  uuid
end

Public Instance Methods

counter(counter) click to toggle source
# File lib/resque_ui/overrides/resque_status/job_with_status.rb, line 55
def counter(counter)
  Resque::Status.counter(counter, uuid)
end
incr_counter(counter) click to toggle source
# File lib/resque_ui/overrides/resque_status/job_with_status.rb, line 51
def incr_counter(counter)
  Resque::Status.incr_counter(counter, uuid)
end
name() click to toggle source
# File lib/resque_ui/overrides/resque_status/job_with_status.rb, line 47
def name
  "#{self.class.name}: #{options.inspect}"
end
safe_perform!() click to toggle source

Run by the Resque::Worker when processing this job. It wraps the perform method ensuring that the final status of the job is set regardless of error. If an error occurs within the job’s work, it will set the status as failed and re-raise the error.

# File lib/resque_ui/overrides/resque_status/job_with_status.rb, line 25
def safe_perform!
  unless should_kill? || (status && status.killed?)
    set_status({'status' => 'working'})
    perform
    kill! if should_kill?
    completed unless status && status.completed?
    on_success if respond_to?(:on_success)
  end
rescue Killed
  logger.info "Job #{self} Killed at #{Time.now}"
  Resque::Status.killed(uuid)
  on_killed if respond_to?(:on_killed)
rescue => e
  logger.error e
  failed("The task failed because of an error: #{e}")
  if respond_to?(:on_failure)
    on_failure(e)
  else
    raise e
  end
end
tick(*messages) click to toggle source

sets the status of the job for the current iteration. You should use the at method if you have actual numbers to track the iteration count. This will kill the job if it has been added to the kill list with Resque::Status.kill()

# File lib/resque_ui/overrides/resque_status/job_with_status.rb, line 16
def tick(*messages)
  kill! if should_kill? || status.killed?
  set_status({'status' => 'working'}, *messages)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.