Module: Faktory::Job

Defined in:
lib/faktory/job.rb

Overview

Include this module in your Job class and you can easily create asynchronous jobs:

class HardJob

include Faktory::Job

def perform(*args)
  # do some work
end

end

Then in your Rails app, you can do this:

HardJob.perform_async(1, 2, 3)

Note that perform_async is a class method, perform is an instance method.

Defined Under Namespace

Modules: ClassMethods Classes: Setter

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#jidObject

Returns the value of attribute jid.



22
23
24
# File 'lib/faktory/job.rb', line 22

def jid
  @jid
end

Class Method Details

.included(base) ⇒ Object

Raises:

  • (ArgumentError)


24
25
26
27
28
29
# File 'lib/faktory/job.rb', line 24

def self.included(base)
  raise ArgumentError, "You cannot include Faktory::Job in an ActiveJob: #{base.name}" if base.ancestors.any? {|c| c.name == 'ActiveJob::Base' }

  base.extend(ClassMethods)
  base.faktory_class_attribute :faktory_options_hash
end

Instance Method Details

#loggerObject



31
32
33
# File 'lib/faktory/job.rb', line 31

def logger
  Faktory.logger
end