module Roundhouse::Worker

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

class HardWorker

include Roundhouse::Worker

def perform(*args)
  # do some work
end

end

Then in your Rails app, you can do this:

HardWorker.perform_async(queue_id, 1, 2, 3)

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

Attributes

jid[RW]

Public Class Methods

clear_all() click to toggle source

Clear all queued jobs across all workers

# File lib/roundhouse/testing.rb, line 181
def clear_all
  jobs.clear
end
drain_all() click to toggle source

Drain all queued jobs across all workers

# File lib/roundhouse/testing.rb, line 186
def drain_all
  until jobs.values.all?(&:empty?) do
    jobs.keys.each(&:drain)
  end
end
included(base) click to toggle source
# File lib/roundhouse/worker.rb, line 26
def self.included(base)
  raise ArgumentError, "You cannot include Roundhouse::Worker in an ActiveJob: #{base.name}" if base.ancestors.any? {|c| c.name == 'ActiveJob::Base' }

  base.extend(ClassMethods)
  base.class_attribute :roundhouse_options_hash
  base.class_attribute :roundhouse_retry_in_block
  base.class_attribute :roundhouse_retries_exhausted_block
end

Public Instance Methods

logger() click to toggle source
# File lib/roundhouse/worker.rb, line 35
def logger
  Roundhouse.logger
end