nesquena / backburner

Simple and reliable beanstalkd job queue for ruby
http://nesquena.github.com/backburner
MIT License
428 stars 68 forks source link

Allow lambdas to determine queue name #99

Closed contentfree closed 9 years ago

contentfree commented 9 years ago

This changeset allows one-off or pre-configured usages of lambdas to determine the queue name. (I personally use this in Delayed::Job for different video rendering queues.)

A couple examples:

# Pre-configured queue using lambdas
class Example
  include Backburner::Queue
  queue lambda { |klass| klass.get_queue_name }

  def self.get_queue_name; "#{name.downcase}-jobs" end

  def hard_task; "do some work" end
end

# One-off usage of lambas
Backburner::Worker.enqueue(Example, :hard_task, queue: lambda { |klass| klass.get_queue_name })
nesquena commented 9 years ago

Can you add a description of how this works to the README? I would like to merge this in and cut a new release soon.

contentfree commented 9 years ago

Rebased to the current master and added an example to the README.

nesquena commented 9 years ago

Thanks!