Module: Resque

Defined in:
lib/hirefire/workers/resque.rb,
lib/hirefire/workers/resque/job.rb,
lib/hirefire/workers/resque/worker.rb

Overview

HireFire This is a HireFire modified version of the official Resque::Worker class

Defined Under Namespace

Classes: Job, Worker

Class Method Summary collapse

Class Method Details

.enqueue(klass, *args) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/hirefire/workers/resque.rb', line 14

def self.enqueue(klass, *args)
  Job.create(queue_from_class(klass), klass, *args)

  ##
  # HireFire Hook
  # After a new job gets queued, we command the current environment
  # to calculate the amount of workers we need to process the jobs
  # that are currently queued, and hire them accordingly.
  if ::Resque.info[:working].to_i == 0 \
  or ::Resque.info[:jobs] == 1
    ::Resque::Job.environment.hire
  end

  Plugin.after_enqueue_hooks(klass).each do |hook|
    klass.send(hook, *args)
  end
end