Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow queue name of NULL to mean "this worker can do jobs with no queue specified" #457

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.textile
Expand Up @@ -170,6 +170,11 @@ QUEUE=tracking rake jobs:work
QUEUES=mailers,tasks rake jobs:work
</pre>

Specify a queue name of NULL to allow a worker to do jobs that have no queue specified:
<pre>
QUEUES=mailers,NULL rake jobs:work
</pre>

h2. Custom Jobs

Jobs are simple ruby objects with a method called perform. Any object which responds to perform can be stuffed into the jobs table. Job objects are serialized to yaml so that they can later be resurrected by the job runner.
Expand Down
4 changes: 4 additions & 0 deletions lib/delayed/worker.rb
Expand Up @@ -53,6 +53,10 @@ def self.reset
RAILS_DEFAULT_LOGGER
end

def self.queues=(queues)
@@queues = queues.map{|q| q == 'NULL' ? nil : q }
end

def self.backend=(backend)
if backend.is_a? Symbol
require "delayed/serialization/#{backend}"
Expand Down
9 changes: 9 additions & 0 deletions spec/worker_spec.rb
Expand Up @@ -21,6 +21,15 @@
end
end

describe "queues=" do
before do
Delayed::Worker.queues = %w(mailers NULL)
end
it 'sets the array to include nil' do
expect(Delayed::Worker.queues).to eq(['mailers', nil])
end
end

context "worker read-ahead" do
before do
@read_ahead = Delayed::Worker.read_ahead
Expand Down