Module: Backburner

Defined in:
lib/backburner.rb,
lib/backburner/cli.rb,
lib/backburner/job.rb,
lib/backburner/hooks.rb,
lib/backburner/queue.rb,
lib/backburner/logger.rb,
lib/backburner/worker.rb,
lib/backburner/helpers.rb,
lib/backburner/version.rb,
lib/backburner/connection.rb,
lib/backburner/async_proxy.rb,
lib/backburner/performable.rb,
lib/backburner/allq_wrapper.rb,
lib/backburner/configuration.rb,
lib/backburner/workers/simple.rb,
lib/backburner/workers/forking.rb,
lib/backburner/workers/threading.rb,
lib/backburner/workers/threads_on_fork.rb

Defined Under Namespace

Modules: Helpers, Logger, Performable, Queue, Workers Classes: AllQJob, AllQWrapper, AllqWatcher, AsyncProxy, BasicObject, CLI, Configuration, Connection, Hooks, Job, Worker

Constant Summary collapse

VERSION =
"1.0.50"

Class Method Summary collapse

Class Method Details

.configurationObject

Returns the configuration options set for Backburner

Examples:

Backburner.configuration.beanstalk_url => false


64
65
66
# File 'lib/backburner.rb', line 64

def configuration
  @_configuration ||= Configuration.new
end

.configure {|configuration| ... } ⇒ Object

Yields a configuration block

Examples:

Backburner.configure do |config|
  config.beanstalk_url = "beanstalk://..."
end

Yields:



54
55
56
57
# File 'lib/backburner.rb', line 54

def configure(&block)
  yield(configuration)
  configuration
end

.default_queuesObject

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

Examples:

Backburner.default_queues << "foo"
Backburner.default_queues => ["foo", "bar"]


74
75
76
# File 'lib/backburner.rb', line 74

def default_queues
  configuration.default_queues
end

.enqueue(job_class, args, opts = {}) ⇒ Object

Enqueues a job to be performed with given arguments.

Examples:

Backburner.enqueue NewsletterSender, self.id, user.id


29
30
31
32
# File 'lib/backburner.rb', line 29

def enqueue(job_class, args, opts={})
  opts[:shard_key] = "X" if  opts[:shard_key].nil? 
  Backburner::Worker.enqueue(job_class, args, opts)
end

.work(*tubes) ⇒ Object

Begins working on jobs enqueued with optional tubes specified

Examples:

Backburner.work('newsletter_sender', 'test_job')
Backburner.work('newsletter_sender', 'test_job', :worker => NotSimpleWorker)


41
42
43
44
45
# File 'lib/backburner.rb', line 41

def work(*tubes)
  options = tubes.last.is_a?(Hash) ? tubes.pop : {}
  worker_class = options[:worker] || configuration.default_worker
  worker_class.start(tubes)
end