mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
Remove .via, not sure it's necessary.
This commit is contained in:
parent
f4b1d3c751
commit
dd798bb6be
2 changed files with 1 additions and 30 deletions
|
@ -34,25 +34,6 @@ module Sidekiq
|
||||||
Sidekiq.logger
|
Sidekiq.logger
|
||||||
end
|
end
|
||||||
|
|
||||||
# Allows sharding of jobs across any number of Redis instances. All jobs
|
|
||||||
# defined within the block will use the given Redis connection pool.
|
|
||||||
#
|
|
||||||
# pool = ConnectionPool.new { Redis.new }
|
|
||||||
# Sidekiq::Worker.via(pool) do
|
|
||||||
# SomeWorker.perform_async(1,2,3)
|
|
||||||
# SomeOtherWorker.perform_async(1,2,3)
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# Generally this is only needed for very large Sidekiq installs processing
|
|
||||||
# more than thousands jobs per second.
|
|
||||||
def self.via(pool)
|
|
||||||
raise ArgumentError, "No pool given" if pool.nil?
|
|
||||||
Thread.current[:sidekiq_via_pool] = pool
|
|
||||||
yield
|
|
||||||
ensure
|
|
||||||
Thread.current[:sidekiq_via_pool] = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
module ClassMethods
|
module ClassMethods
|
||||||
|
|
||||||
def perform_async(*args)
|
def perform_async(*args)
|
||||||
|
@ -100,7 +81,7 @@ module Sidekiq
|
||||||
end
|
end
|
||||||
|
|
||||||
def client_push(item) # :nodoc:
|
def client_push(item) # :nodoc:
|
||||||
pool = Thread.current[:sidekiq_via_pool] || get_sidekiq_options['pool'] || Sidekiq.redis_pool
|
pool = get_sidekiq_options['pool'] || Sidekiq.redis_pool
|
||||||
Sidekiq::Client.new(pool).push(item.stringify_keys)
|
Sidekiq::Client.new(pool).push(item.stringify_keys)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -246,16 +246,6 @@ class TestClient < Sidekiq::Test
|
||||||
DWorker.perform_async(1,2,3)
|
DWorker.perform_async(1,2,3)
|
||||||
conn.verify
|
conn.verify
|
||||||
end
|
end
|
||||||
it 'allows #via to point to different Redi' do
|
|
||||||
conn = MiniTest::Mock.new
|
|
||||||
conn.expect(:multi, [0, 1])
|
|
||||||
default = Sidekiq::Client.redis_pool
|
|
||||||
Sidekiq::Client.via(ConnectionPool.new(size: 1) { conn }) do
|
|
||||||
CWorker.perform_async(1,2,3)
|
|
||||||
end
|
|
||||||
assert_equal default, Sidekiq::Client.redis_pool
|
|
||||||
conn.verify
|
|
||||||
end
|
|
||||||
it 'allows Resque helpers to point to different Redi' do
|
it 'allows Resque helpers to point to different Redi' do
|
||||||
conn = MiniTest::Mock.new
|
conn = MiniTest::Mock.new
|
||||||
conn.expect(:zadd, 1, [String, Array])
|
conn.expect(:zadd, 1, [String, Array])
|
||||||
|
|
Loading…
Add table
Reference in a new issue