Class: Stormtroopers::DelayedJobFactory

Inherits:
Factory
  • Object
show all
Defined in:
lib/stormtroopers/factory/delayed_job.rb

Instance Attribute Summary

Attributes inherited from Factory

#name, #options

Instance Method Summary collapse

Methods inherited from Factory

#initialize, #logger

Constructor Details

This class inherits a constructor from Stormtroopers::Factory

Instance Method Details

#produceObject



3
4
5
6
7
8
9
10
# File 'lib/stormtroopers/factory/delayed_job.rb', line 3

def produce
  worker = Delayed::Worker.new(options)
  worker.name = "rand #{Time.now.utc.to_f} #{rand(1000)}"
  if job = Delayed::Job.reserve(worker)
    logger.info("#{self.name} producing trooper to run #{job.queue} job #{job.id}")
    DelayedJobTrooper.new(job)
  end
end