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

Merge branch 'master' into queue_weights

This commit is contained in:
Ryan LeCompte 2012-04-03 20:19:45 -07:00
commit c66d58a235
4 changed files with 22 additions and 18 deletions

View file

@ -2,7 +2,8 @@ HEAD
-----------
- Fix fetch breaking retry when used with Redis namespaces. [#109]
- Redis connection now just a plain ConnectionPool, not CP::Wrapper.
- Capistrano initial deploy fix [#106]
0.11.0
-----------

View file

@ -8,12 +8,12 @@ Capistrano::Configuration.instance.load do
desc "Quiet sidekiq (stop accepting new work)"
task :quiet do
run "cd #{current_path} && bundle exec sidekiqctl quiet #{current_path}/tmp/pids/sidekiq.pid"
run "cd #{current_path} && if [ -f #{current_path}/tmp/pids/sidekiq.pid ]; then bundle exec sidekiqctl quiet #{current_path}/tmp/pids/sidekiq.pid ; fi"
end
desc "Stop sidekiq"
task :stop do
run "cd #{current_path} && bundle exec sidekiqctl stop #{current_path}/tmp/pids/sidekiq.pid #{fetch :sidekiq_timeout}"
run "cd #{current_path} && if [ -f #{current_path}/tmp/pids/sidekiq.pid ]; then bundle exec sidekiqctl stop #{current_path}/tmp/pids/sidekiq.pid #{fetch :sidekiq_timeout} ; fi"
end
desc "Start sidekiq"

View file

@ -6,7 +6,8 @@ module Sidekiq
class RedisConnection
def self.create(options={})
url = options[:url] || ENV['REDISTOGO_URL'] || 'redis://localhost:6379/0'
ConnectionPool::Wrapper.new(:timeout => 1, :size => (options[:size] || Sidekiq.options[:concurrency] || 25)) do
size = (options[:size] || Sidekiq.options[:concurrency] || 25)
ConnectionPool.new(:timeout => 1, :size => size) do
build_client(url, options[:namespace])
end
end

View file

@ -55,23 +55,25 @@ class TestStats < MiniTest::Unit::TestCase
msg = { 'class' => DumbWorker.to_s, 'args' => [nil] }
boss = MiniTest::Mock.new
assert_equal [], @redis.smembers('workers')
assert_equal 0, @redis.get('stat:failed').to_i
assert_equal 0, @redis.get('stat:processed').to_i
@redis.with do |conn|
assert_equal [], conn.smembers('workers')
assert_equal 0, conn.get('stat:failed').to_i
assert_equal 0, conn.get('stat:processed').to_i
processor = Sidekiq::Processor.new(boss)
assert_equal 1, @redis.smembers('workers').size
processor = Sidekiq::Processor.new(boss)
assert_equal 1, conn.smembers('workers').size
pstr = processor.to_s
assert_raises RuntimeError do
processor.process(msg, 'xyzzy')
pstr = processor.to_s
assert_raises RuntimeError do
processor.process(msg, 'xyzzy')
end
set = conn.smembers('workers')
assert_equal 0, set.size
assert_equal 1, conn.get('stat:failed').to_i
assert_equal 1, conn.get('stat:processed').to_i
assert_equal nil, conn.get("stat:processed:#{pstr}")
end
set = @redis.smembers('workers')
assert_equal 0, set.size
assert_equal 1, @redis.get('stat:failed').to_i
assert_equal 1, @redis.get('stat:processed').to_i
assert_equal nil, @redis.get("stat:processed:#{pstr}")
end
end