diff --git a/lib/sidekiq.rb b/lib/sidekiq.rb index 494ab5d2..88b35193 100644 --- a/lib/sidekiq.rb +++ b/lib/sidekiq.rb @@ -56,32 +56,15 @@ module Sidekiq def self.redis(&block) @redis ||= Sidekiq::RedisConnection.create - if block_given? - @redis.with(&block) - else - Sidekiq::Util.logger.info "***************************************************** -Sidekiq.redis now takes a block: - - Sidekiq.redis { |connection| connection.smembers('myset') } - -Please update your code accordingly. -Called from #{caller[0]} -*****************************************************" - @redis - end + raise ArgumentError, "requires a block" if !block + @redis.with(&block) end def self.redis=(hash) - @redis = if hash.is_a?(Hash) - RedisConnection.create(hash) + if hash.is_a?(Hash) + @redis = RedisConnection.create(hash) else - Sidekiq::Util.logger.info "***************************************************** -Sidekiq.redis now takes a Hash: -old: Sidekiq.redis = Sidekiq::RedisConnection.create(:url => 'redis://foo.com', :namespace => 'abc', :size => 12) -new: Sidekiq.redis = { :url => 'redis://foo.com', :namespace => 'xyz', :size => 12 } -Called from #{caller[0]} -*****************************************************" - hash + @redis = hash end end diff --git a/lib/sidekiq/processor.rb b/lib/sidekiq/processor.rb index f377d2a2..61f6f19c 100644 --- a/lib/sidekiq/processor.rb +++ b/lib/sidekiq/processor.rb @@ -12,10 +12,6 @@ module Sidekiq include Util include Celluloid - def self.middleware - raise "Sidekiq::Processor.middleware is now Sidekiq.server_middleware" - end - def self.default_middleware Middleware::Chain.new do |m| m.add Middleware::Server::ExceptionHandler diff --git a/lib/sidekiq/web.rb b/lib/sidekiq/web.rb index 3bdeae72..3ae8ac6d 100644 --- a/lib/sidekiq/web.rb +++ b/lib/sidekiq/web.rb @@ -43,8 +43,7 @@ module Sidekiq workers.each do |name| conn.srem('workers', name) # if name =~ /:#{process_id}-/ end - end - + end end def workers @@ -106,8 +105,8 @@ module Sidekiq end post "/reset" do - reset_worker_list - redirect '/sidekiq' + reset_worker_list + redirect root_path end get "/queues/:name" do diff --git a/test/test_client.rb b/test/test_client.rb index 8b7c229a..734159ce 100644 --- a/test/test_client.rb +++ b/test/test_client.rb @@ -6,7 +6,7 @@ class TestClient < MiniTest::Unit::TestCase describe 'with real redis' do before do Sidekiq.redis = REDIS - Sidekiq.redis.flushdb + Sidekiq.redis {|c| c.flushdb } end it 'does not push duplicate messages when configured for unique only' do @@ -15,13 +15,13 @@ class TestClient < MiniTest::Unit::TestCase chain.add Sidekiq::Middleware::Client::UniqueJobs end 10.times { Sidekiq::Client.push('customqueue', 'class' => 'Foo', 'args' => [1, 2]) } - assert_equal 1, Sidekiq.redis.llen("queue:customqueue") + assert_equal 1, Sidekiq.redis {|c| c.llen("queue:customqueue") } end it 'does push duplicate messages when not configured for unique only' do Sidekiq.client_middleware.remove(Sidekiq::Middleware::Client::UniqueJobs) 10.times { Sidekiq::Client.push('customqueue2', 'class' => 'Foo', 'args' => [1, 2]) } - assert_equal 10, Sidekiq.redis.llen("queue:customqueue2") + assert_equal 10, Sidekiq.redis {|c| c.llen("queue:customqueue2") } end end diff --git a/test/test_extensions.rb b/test/test_extensions.rb index a7e9b805..a84ef98f 100644 --- a/test/test_extensions.rb +++ b/test/test_extensions.rb @@ -11,7 +11,7 @@ class TestExtensions < MiniTest::Unit::TestCase describe 'sidekiq extensions' do before do Sidekiq.redis = REDIS - Sidekiq.redis.flushdb + Sidekiq.redis {|c| c.flushdb } end class MyModel < ActiveRecord::Base @@ -22,10 +22,10 @@ class TestExtensions < MiniTest::Unit::TestCase it 'allows delayed exection of ActiveRecord class methods' do assert_equal [], Sidekiq::Client.registered_queues - assert_equal 0, Sidekiq.redis.llen('queue:default') + assert_equal 0, Sidekiq.redis {|c| c.llen('queue:default') } MyModel.delay.long_class_method assert_equal ['default'], Sidekiq::Client.registered_queues - assert_equal 1, Sidekiq.redis.llen('queue:default') + assert_equal 1, Sidekiq.redis {|c| c.llen('queue:default') } end class UserMailer < ActionMailer::Base @@ -36,10 +36,10 @@ class TestExtensions < MiniTest::Unit::TestCase it 'allows delayed delivery of ActionMailer mails' do assert_equal [], Sidekiq::Client.registered_queues - assert_equal 0, Sidekiq.redis.llen('queue:default') + assert_equal 0, Sidekiq.redis {|c| c.llen('queue:default') } UserMailer.delay.greetings(1, 2) assert_equal ['default'], Sidekiq::Client.registered_queues - assert_equal 1, Sidekiq.redis.llen('queue:default') + assert_equal 1, Sidekiq.redis {|c| c.llen('queue:default') } end end diff --git a/test/test_manager.rb b/test/test_manager.rb index 3952dab2..7896c441 100644 --- a/test/test_manager.rb +++ b/test/test_manager.rb @@ -9,7 +9,7 @@ class TestManager < MiniTest::Unit::TestCase describe 'with redis' do before do Sidekiq.redis = REDIS - Sidekiq.redis.flushdb + Sidekiq.redis {|c| c.flushdb } $processed = 0 $mutex = Mutex.new end diff --git a/test/test_stats.rb b/test/test_stats.rb index 821afac3..88b4c565 100644 --- a/test/test_stats.rb +++ b/test/test_stats.rb @@ -6,7 +6,7 @@ class TestStats < MiniTest::Unit::TestCase describe 'with redis' do before do @redis = Sidekiq.redis = REDIS - Sidekiq.redis.flushdb + Sidekiq.redis {|c| c.flushdb } end class DumbWorker diff --git a/test/test_web.rb b/test/test_web.rb index 1f199dc6..0ecfca2b 100644 --- a/test/test_web.rb +++ b/test/test_web.rb @@ -13,7 +13,7 @@ class TestWeb < MiniTest::Unit::TestCase before do Sidekiq.redis = REDIS - Sidekiq.redis.flushdb + Sidekiq.redis {|c| c.flushdb } end class WebWorker diff --git a/web/views/index.slim b/web/views/index.slim index d21408b8..9c91ab0c 100644 --- a/web/views/index.slim +++ b/web/views/index.slim @@ -5,8 +5,6 @@ p Failed: #{failed} p Workers: #{workers.size} p Retries Pending: #{retry_count} - form(action="/sidekiq/reset" method="post") - button(class="btn" type="submit") Clear worker list .tabbable ul.nav.nav-tabs @@ -33,6 +31,8 @@ td= msg['payload']['args'].inspect[0..100] - else td colspan=3 Idle + form action="#{root_path}reset" method="post" + button.btn type="submit" Clear worker list #queues.tab-pane table class="table table-striped table-bordered"