Skip to content

Commit

Permalink
Merge branch 'feature/default-queue'
Browse files Browse the repository at this point in the history
  • Loading branch information
betamatt committed Jun 5, 2012
2 parents ceb6487 + 8d5052e commit 0333bf1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/delayed/backend/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

This comment has been minimized.

Copy link
@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
Expand Down
3 changes: 3 additions & 0 deletions lib/delayed/worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions spec/message_sending_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

1 comment on commit 0333bf1

@metaskills
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any chance you can do a gem release with this?

Please sign in to comment.