Permalink
Browse files

Merge branch 'feature/default-queue'

  • Loading branch information...
2 parents ceb6487 + 8d5052e commit 0333bf17109d1ddd3fc86cc758e0725ec76031b1 @betamatt betamatt committed Jun 5, 2012
Showing with 12 additions and 1 deletion.
  1. +2 −1 lib/delayed/backend/base.rb
  2. +3 −0 lib/delayed/worker.rb
  3. +7 −0 spec/message_sending_spec.rb
@@ -9,7 +9,8 @@ module ClassMethods
# Add a job to the queue
def enqueue(*args)
options = {
- :priority => Delayed::Worker.default_priority
+ :priority => Delayed::Worker.default_priority,
+ :queue => Delayed::Worker.default_queue_name
@ngan
ngan Aug 21, 2012

Would be nice to to_s this if it's not nil. That way we can use symbol as queue name?

}.merge!(args.extract_options!)
options[:payload_object] ||= args.shift
@@ -20,6 +20,9 @@ class Worker
:default_priority, :sleep_delay, :logger, :delay_jobs, :queues,
:read_ahead, :plugins, :destroy_failed_jobs
+ # Named queue into which jobs are enqueued by default
+ cattr_accessor :default_queue_name
+
cattr_reader :backend
# name_prefix is ignored if name is set directly
@@ -83,6 +83,13 @@ def tell
Delayed::Worker.default_priority = 0
end
+ it "should set default queue name" do
+ Delayed::Worker.default_queue_name = 'abbazabba'
+ job = FairyTail.delay.to_s
+ job.queue.should == 'abbazabba'
+ Delayed::Worker.default_queue_name = nil
+ end
+
it "should set job options" do
run_at = Time.parse('2010-05-03 12:55 AM')
job = FairyTail.delay(:priority => 20, :run_at => run_at).to_s

1 comment on commit 0333bf1

@metaskills

Any chance you can do a gem release with this?

Please sign in to comment.