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

Remove queue weight support

This commit is contained in:
Mike Perham 2012-03-30 21:43:12 -07:00
parent 80f0559c53
commit 23f468819c
3 changed files with 17 additions and 18 deletions

View file

@ -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
-----------

View file

@ -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,16 +172,14 @@ 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
def parse_queues(opts, q)
(opts[:queues] ||= []) << q
end
end
end
end

View file

@ -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