diff --git a/lib/shoryuken/manager.rb b/lib/shoryuken/manager.rb index ad940a02..f954f04c 100644 --- a/lib/shoryuken/manager.rb +++ b/lib/shoryuken/manager.rb @@ -11,7 +11,8 @@ class Manager trap_exit :processor_died def initialize(condvar) - @count = Shoryuken.options[:concurrency] || 25 + @count = Shoryuken.options[:concurrency] || 25 + raise(ArgumentError, "Concurrency value #{@count} is invalid, it needs to be a positive number") unless @count > 0 @queues = Shoryuken.queues.dup.uniq @finished = condvar diff --git a/spec/shoryuken/manager_spec.rb b/spec/shoryuken/manager_spec.rb index c58d0741..0ef0b6ba 100644 --- a/spec/shoryuken/manager_spec.rb +++ b/spec/shoryuken/manager_spec.rb @@ -1,13 +1,22 @@ require 'spec_helper' require 'shoryuken/manager' -describe Shoryuken::Manager do +RSpec.describe Shoryuken::Manager do subject do condvar = double(:condvar) allow(condvar).to receive(:signal).and_return(nil) Shoryuken::Manager.new(condvar) end + describe 'Invalid concurrency setting' do + it 'raises ArgumentError if concurrency is not positive number' do + Shoryuken.options[:concurrency] = -1 + expect { Shoryuken::Manager.new(nil) } + .to raise_error(ArgumentError, 'Concurrency value -1 is invalid, it needs to be a positive number') + end + + end + describe 'Auto Scaling' do it 'decreases weight' do queue1 = 'shoryuken'