1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00

Standardize on concurrency, not processor_count

This commit is contained in:
jc00ke 2012-02-16 09:45:55 -08:00
parent 6f22320aee
commit ea8c9f72b5
5 changed files with 12 additions and 13 deletions

View file

@ -93,7 +93,7 @@ module Sidekiq
def parse_options(argv) def parse_options(argv)
@options = { @options = {
:queues => [], :queues => [],
:processor_count => 25, :concurrency => 25,
:require => '.', :require => '.',
:environment => nil, :environment => nil,
} }
@ -125,7 +125,7 @@ module Sidekiq
end end
o.on '-c', '--concurrency INT', "processor threads to use" do |arg| o.on '-c', '--concurrency INT', "processor threads to use" do |arg|
@options[:processor_count] = arg.to_i @options[:concurrency] = arg.to_i
end end
o.on '-P', '--pidfile PATH', "path to pidfile" do |arg| o.on '-P', '--pidfile PATH', "path to pidfile" do |arg|
@ -172,7 +172,10 @@ module Sidekiq
opts.each do |option, value| opts.each do |option, value|
@options[option.intern] ||= value @options[option.intern] ||= value
end 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] set_logger_level_to_debug if @options[:verbose]
end end
end end

View file

@ -25,7 +25,7 @@ module Sidekiq
def initialize(options={}) def initialize(options={})
logger.info "Booting sidekiq #{Sidekiq::VERSION} with Redis at #{redis.client.location}" logger.info "Booting sidekiq #{Sidekiq::VERSION} with Redis at #{redis.client.location}"
logger.debug { options.inspect } logger.debug { options.inspect }
@count = options[:processor_count] || 25 @count = options[:concurrency] || 25
@queues = options[:queues] @queues = options[:queues]
@done_callback = nil @done_callback = nil

View file

@ -5,7 +5,7 @@ server: 127.0.0.1:1234
environment: xzibit environment: xzibit
require: ./test/fake_env.rb require: ./test/fake_env.rb
pidfile: /tmp/sidekiq-config-test.pid pidfile: /tmp/sidekiq-config-test.pid
processor_count: 50 concurrency: 50
queues: queues:
- [often, 2] - [often, 2]
- [seldom, 1] - [seldom, 1]

View file

@ -22,7 +22,7 @@ class TestCli < MiniTest::Unit::TestCase
it 'changes concurrency' do it 'changes concurrency' do
@cli.parse(['sidekiq', '-c', '60', '-r', './test/fake_env.rb']) @cli.parse(['sidekiq', '-c', '60', '-r', './test/fake_env.rb'])
assert_equal 60, @cli.options[:processor_count] assert_equal 60, @cli.options[:concurrency]
end end
it 'changes queues' do it 'changes queues' do
@ -124,8 +124,8 @@ class TestCli < MiniTest::Unit::TestCase
File.unlink @tmp_path if File.exist? @tmp_path File.unlink @tmp_path if File.exist? @tmp_path
end end
it 'uses processor count flag' do it 'uses concurrency flag' do
assert_equal 100, @cli.options[:processor_count] assert_equal 100, @cli.options[:concurrency]
end end
it 'uses namespace flag' do it 'uses namespace flag' do
@ -140,10 +140,6 @@ class TestCli < MiniTest::Unit::TestCase
assert_equal 'snoop', @cli.options[:environment] assert_equal 'snoop', @cli.options[:environment]
end end
it 'uses concurrency flag' do
assert_equal 100, @cli.options[:processor_count]
end
it 'uses pidfile flag' do it 'uses pidfile flag' do
assert_equal @tmp_path, @cli.options[:pidfile] assert_equal @tmp_path, @cli.options[:pidfile]
end end

View file

@ -30,7 +30,7 @@ class TestManager < MiniTest::Unit::TestCase
Sidekiq::Client.push(:foo, 'class' => IntegrationWorker, 'args' => [1, 3]) Sidekiq::Client.push(:foo, 'class' => IntegrationWorker, 'args' => [1, 3])
q = TimedQueue.new q = TimedQueue.new
mgr = Sidekiq::Manager.new(:queues => [:foo], :processor_count => 2) mgr = Sidekiq::Manager.new(:queues => [:foo], :concurrency => 2)
mgr.when_done do |_| mgr.when_done do |_|
q << 'done' if $processed == 2 q << 'done' if $processed == 2
end end