module Backburner

Constants

VERSION

Public Class Methods

configuration() click to toggle source

Returns the configuration options set for Backburner

@example

Backburner.configuration.beanstalk_url => false
# File lib/backburner.rb, line 62
def configuration
  @_configuration ||= Configuration.new
end
configure() { |configuration| ... } click to toggle source

Yields a configuration block

@example

Backburner.configure do |config|
  config.beanstalk_url = "beanstalk://..."
end
# File lib/backburner.rb, line 52
def configure(&block)
  yield(configuration)
  configuration
end
default_queues() click to toggle source

Returns the queues that are processed by default if none are specified

@example

Backburner.default_queues << "foo"
Backburner.default_queues => ["foo", "bar"]
# File lib/backburner.rb, line 72
def default_queues
  configuration.default_queues
end
enqueue(job_class, args, opts={}) click to toggle source

Enqueues a job to be performed with given arguments.

@example

Backburner.enqueue NewsletterSender, self.id, user.id
# File lib/backburner.rb, line 27
def enqueue(job_class, args, opts={})
  opts[:shard_key] = opts[:shard_key].nil? ? "X" : opts[:shard_key].to_s
  Backburner::Worker.enqueue(job_class, args, opts)
end
work(*tubes) click to toggle source

Begins working on jobs enqueued with optional tubes specified

@example

Backburner.work('newsletter_sender', 'test_job')
Backburner.work('newsletter_sender', 'test_job', :worker => NotSimpleWorker)
# File lib/backburner.rb, line 39
def work(*tubes)
  options = tubes.last.is_a?(Hash) ? tubes.pop : {}
  worker_class = options[:worker] || configuration.default_worker
  worker_class.start(tubes)
end