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
31
# 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 enqueued we check to see if there are currently
  # any workers up and running. If this is the case then we do nothing and
  # let the worker pick up the jobs (and potentially hire more workers)
  #
  # If there are no workers, then we manually hire workers.
  if ::Resque::Job.workers == 0
    ::Resque::Job.environment.hire
  end

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