Skip to content

Commit

Permalink
Merge branch 'bbaja42-barisa/check-for-negative-concurrency-value'
Browse files Browse the repository at this point in the history
  • Loading branch information
Pablo Cantero committed Feb 14, 2016
2 parents c64085c + 072446b commit 76a3122
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/shoryuken/manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 10 additions & 1 deletion spec/shoryuken/manager_spec.rb
Original file line number Diff line number Diff line change
@@ -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'
Expand Down

0 comments on commit 76a3122

Please sign in to comment.