module RocketJob::Plugins::Job::Worker::ClassMethods

Public Instance Methods

perform_now(args) { |job| ... } click to toggle source

Run this job now.

The job is not saved to the database since it is processed entirely in memory As a result before_save and before_destroy callbacks will not be called. Validations are still called however prior to calling perform

Note:

  • Only batch throttles are checked when perform_now is called.

# File lib/rocket_job/plugins/job/worker.rb, line 19
def perform_now(args)
  job = new(args)
  yield(job) if block_given?
  job.perform_now
  job
end
requeue_dead_server(server_name) click to toggle source

Requeues all jobs that were running on a server that died

# File lib/rocket_job/plugins/job/worker.rb, line 27
def requeue_dead_server(server_name)
  # Need to requeue paused, failed since user may have transitioned job before it finished
  with(read: {mode: :primary}) do |conn|
    conn.where(:state.in => %i[running paused failed]).each do |job|
      job.requeue!(server_name) if job.may_requeue?(server_name)
    end
  end
end