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 symbol as a queue name in shoryuken_options #177

Merged
merged 1 commit into from
Jan 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/shoryuken/worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ def normalize_worker_queue!
@shoryuken_options['queue'] = queue
end

case @shoryuken_options['queue']
when Array
@shoryuken_options['queue'].map!(&:to_s)
when Symbol
@shoryuken_options['queue'] = @shoryuken_options['queue'].to_s
end

[@shoryuken_options['queue']].flatten.compact.each(&method(:register_worker))
end

Expand Down
22 changes: 22 additions & 0 deletions spec/shoryuken/worker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,28 @@ class GlobalDefaultsTestWorker
expect(GlobalDefaultsTestWorker.get_shoryuken_options['auto_delete']).to eq true
expect(GlobalDefaultsTestWorker.get_shoryuken_options['batch']).to eq false
end

it 'accepts a symbol as a queue and converts to string' do
class SymbolQueueTestWorker
include Shoryuken::Worker

shoryuken_options queue: :default
end

expect(SymbolQueueTestWorker.get_shoryuken_options['queue']).to eq 'default'
end

it 'accepts an array that contains symbols as a queue and converts to string' do
class WorkerMultipleSymbolQueues
include Shoryuken::Worker

shoryuken_options queue: %i[symbol_queue1 symbol_queue2 symbol_queue3]
end

expect(Shoryuken.worker_registry.workers('symbol_queue1')).to eq([WorkerMultipleSymbolQueues])
expect(Shoryuken.worker_registry.workers('symbol_queue2')).to eq([WorkerMultipleSymbolQueues])
expect(Shoryuken.worker_registry.workers('symbol_queue3')).to eq([WorkerMultipleSymbolQueues])
end
end

describe '.server_middleware' do
Expand Down