diff --git a/Changes.md b/Changes.md index 8514df1a..e8c9a907 100644 --- a/Changes.md +++ b/Changes.md @@ -2,6 +2,11 @@ HEAD ----------- - Add version CLI option +- NO POLL! Sidekiq no longer polls Redis, leading to lower network + utilization and lower latency for message processing. As a side + effect of this change, queue weights are no longer supported. If you + wish to process multiple queues, list them in the order you want + them processed: `sidekiq -q critical -q high -q default -q low` 0.10.1 ----------- diff --git a/lib/sidekiq/cli.rb b/lib/sidekiq/cli.rb index 3392de9f..473bc5bb 100644 --- a/lib/sidekiq/cli.rb +++ b/lib/sidekiq/cli.rb @@ -96,7 +96,6 @@ module Sidekiq def validate! options[:queues] << 'default' if options[:queues].empty? - options[:queues].shuffle! if !File.exist?(options[:require]) || (File.directory?(options[:require]) && !File.exist?("#{options[:require]}/config/application.rb")) @@ -113,9 +112,8 @@ module Sidekiq opts = {} @parser = OptionParser.new do |o| - o.on "-q", "--queue QUEUE,WEIGHT", "Queue to process, with optional weight" do |arg| - (q, weight) = arg.split(",") - parse_queues(opts, q, weight) + o.on "-q", "--queue QUEUE", "Queue to process" do |arg| + parse_queues(opts, arg) end o.on "-v", "--verbose", "Print more verbose output" do @@ -174,15 +172,13 @@ module Sidekiq if cli[:config_file] && File.exist?(cli[:config_file]) opts = YAML.load_file cli[:config_file] queues = opts.delete(:queues) || [] - queues.each { |pair| parse_queues(opts, *pair) } + queues.each { |name, _| parse_queues(opts, name) } end opts end - def parse_queues(opts, q, weight) - (weight || 1).to_i.times do - (opts[:queues] ||= []) << q - end + def parse_queues(opts, q) + (opts[:queues] ||= []) << q end end diff --git a/test/test_cli.rb b/test/test_cli.rb index 192cea5a..c83fa1c6 100644 --- a/test/test_cli.rb +++ b/test/test_cli.rb @@ -45,9 +45,9 @@ class TestCli < MiniTest::Unit::TestCase assert_equal 30, Sidekiq.options[:timeout] end - it 'handles weights' do - @cli.parse(['sidekiq', '-q', 'foo,3', '-q', 'bar', '-r', './test/fake_env.rb']) - assert_equal %w(bar foo foo foo), Sidekiq.options[:queues].sort + it 'handles multiple queues' do + @cli.parse(['sidekiq', '-q', 'foo', '-q', 'bar', '-r', './test/fake_env.rb']) + assert_equal %w(foo bar), Sidekiq.options[:queues] end it 'sets verbose' do @@ -110,8 +110,7 @@ class TestCli < MiniTest::Unit::TestCase end it 'sets queues' do - assert_equal 2, Sidekiq.options[:queues].select{ |q| q == 'often' }.length - assert_equal 1, Sidekiq.options[:queues].select{ |q| q == 'seldom' }.length + assert_equal %w(often seldom), Sidekiq.options[:queues] end end @@ -133,8 +132,8 @@ class TestCli < MiniTest::Unit::TestCase '-c', '100', '-r', @tmp_lib_path, '-P', @tmp_path, - '-q', 'often,7', - '-q', 'seldom,3']) + '-q', 'often', + '-q', 'seldom']) end after do @@ -159,8 +158,7 @@ class TestCli < MiniTest::Unit::TestCase end it 'sets queues' do - assert_equal 7, Sidekiq.options[:queues].select{ |q| q == 'often' }.length - assert_equal 3, Sidekiq.options[:queues].select{ |q| q == 'seldom' }.length + assert_equal %w(often seldom), Sidekiq.options[:queues] end end end