mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
Add default Redis client identifier, #3516
This commit is contained in:
parent
1ecfd2cac0
commit
980438c61d
2 changed files with 6 additions and 2 deletions
|
@ -12,6 +12,7 @@ module Sidekiq
|
|||
options[key.to_sym] = options.delete(key)
|
||||
end
|
||||
|
||||
options[:id] ||= "Sidekiq-#{Sidekiq.server? ? "server" : "client"}-PID-#{$$}"
|
||||
options[:url] ||= determine_redis_provider
|
||||
|
||||
size = options[:size] || (Sidekiq.server? ? (Sidekiq.options[:concurrency] + 5) : 5)
|
||||
|
|
|
@ -8,6 +8,7 @@ class TestRedisConnection < Sidekiq::Test
|
|||
it "creates a pooled redis connection" do
|
||||
pool = Sidekiq::RedisConnection.create
|
||||
assert_equal Redis, pool.checkout.class
|
||||
assert_equal "Sidekiq-server-PID-#{$$}", pool.checkout.client.id
|
||||
end
|
||||
|
||||
describe "network_timeout" do
|
||||
|
@ -48,13 +49,15 @@ class TestRedisConnection < Sidekiq::Test
|
|||
it "uses a given :path" do
|
||||
pool = Sidekiq::RedisConnection.create(:path => "/var/run/redis.sock")
|
||||
assert_equal "unix", pool.checkout.client.scheme
|
||||
assert_equal "redis:///var/run/redis.sock/0", pool.checkout.client.id
|
||||
assert_equal "/var/run/redis.sock", pool.checkout.client.location
|
||||
assert_equal 0, pool.checkout.client.db
|
||||
end
|
||||
|
||||
it "uses a given :path and :db" do
|
||||
pool = Sidekiq::RedisConnection.create(:path => "/var/run/redis.sock", :db => 8)
|
||||
assert_equal "unix", pool.checkout.client.scheme
|
||||
assert_equal "redis:///var/run/redis.sock/8", pool.checkout.client.id
|
||||
assert_equal "/var/run/redis.sock", pool.checkout.client.location
|
||||
assert_equal 8, pool.checkout.client.db
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue