From ea8c9f72b5910ea5d70d47b7a10ca2a7d21f68f8 Mon Sep 17 00:00:00 2001 From: jc00ke Date: Thu, 16 Feb 2012 09:45:55 -0800 Subject: [PATCH] Standardize on concurrency, not processor_count --- lib/sidekiq/cli.rb | 9 ++++++--- lib/sidekiq/manager.rb | 2 +- test/config.yml | 2 +- test/test_cli.rb | 10 +++------- test/test_manager.rb | 2 +- 5 files changed, 12 insertions(+), 13 deletions(-) diff --git a/lib/sidekiq/cli.rb b/lib/sidekiq/cli.rb index d41a8094..0c707855 100644 --- a/lib/sidekiq/cli.rb +++ b/lib/sidekiq/cli.rb @@ -93,7 +93,7 @@ module Sidekiq def parse_options(argv) @options = { :queues => [], - :processor_count => 25, + :concurrency => 25, :require => '.', :environment => nil, } @@ -125,7 +125,7 @@ module Sidekiq end o.on '-c', '--concurrency INT', "processor threads to use" do |arg| - @options[:processor_count] = arg.to_i + @options[:concurrency] = arg.to_i end o.on '-P', '--pidfile PATH', "path to pidfile" do |arg| @@ -172,7 +172,10 @@ module Sidekiq opts.each do |option, value| @options[option.intern] ||= value end - @options[:concurrency] = opts['processor_count'] if opts['processor_count'] + concurrency = opts.delete('concurrency') + if @options[:concurrency] == 25 && concurrency + @options[:concurrency] = concurrency + end set_logger_level_to_debug if @options[:verbose] end end diff --git a/lib/sidekiq/manager.rb b/lib/sidekiq/manager.rb index c4b6786a..ec8241d4 100644 --- a/lib/sidekiq/manager.rb +++ b/lib/sidekiq/manager.rb @@ -25,7 +25,7 @@ module Sidekiq def initialize(options={}) logger.info "Booting sidekiq #{Sidekiq::VERSION} with Redis at #{redis.client.location}" logger.debug { options.inspect } - @count = options[:processor_count] || 25 + @count = options[:concurrency] || 25 @queues = options[:queues] @done_callback = nil diff --git a/test/config.yml b/test/config.yml index d01c3e5b..8226425b 100644 --- a/test/config.yml +++ b/test/config.yml @@ -5,7 +5,7 @@ server: 127.0.0.1:1234 environment: xzibit require: ./test/fake_env.rb pidfile: /tmp/sidekiq-config-test.pid -processor_count: 50 +concurrency: 50 queues: - [often, 2] - [seldom, 1] diff --git a/test/test_cli.rb b/test/test_cli.rb index 0aaec63c..0ad5ccc3 100644 --- a/test/test_cli.rb +++ b/test/test_cli.rb @@ -22,7 +22,7 @@ class TestCli < MiniTest::Unit::TestCase it 'changes concurrency' do @cli.parse(['sidekiq', '-c', '60', '-r', './test/fake_env.rb']) - assert_equal 60, @cli.options[:processor_count] + assert_equal 60, @cli.options[:concurrency] end it 'changes queues' do @@ -124,8 +124,8 @@ class TestCli < MiniTest::Unit::TestCase File.unlink @tmp_path if File.exist? @tmp_path end - it 'uses processor count flag' do - assert_equal 100, @cli.options[:processor_count] + it 'uses concurrency flag' do + assert_equal 100, @cli.options[:concurrency] end it 'uses namespace flag' do @@ -140,10 +140,6 @@ class TestCli < MiniTest::Unit::TestCase assert_equal 'snoop', @cli.options[:environment] end - it 'uses concurrency flag' do - assert_equal 100, @cli.options[:processor_count] - end - it 'uses pidfile flag' do assert_equal @tmp_path, @cli.options[:pidfile] end diff --git a/test/test_manager.rb b/test/test_manager.rb index 3704aa44..dd34af8b 100644 --- a/test/test_manager.rb +++ b/test/test_manager.rb @@ -30,7 +30,7 @@ class TestManager < MiniTest::Unit::TestCase Sidekiq::Client.push(:foo, 'class' => IntegrationWorker, 'args' => [1, 3]) q = TimedQueue.new - mgr = Sidekiq::Manager.new(:queues => [:foo], :processor_count => 2) + mgr = Sidekiq::Manager.new(:queues => [:foo], :concurrency => 2) mgr.when_done do |_| q << 'done' if $processed == 2 end