mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
API cleanup, remove deprecations
This commit is contained in:
parent
28761a4614
commit
ee42be39e0
9 changed files with 21 additions and 43 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue