mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
Merge branch 'master' of github.com:mperham/sidekiq
This commit is contained in:
commit
76915f7128
2 changed files with 32 additions and 1 deletions
|
@ -9,9 +9,10 @@ module Sidekiq
|
||||||
driver = options[:driver] || 'ruby'
|
driver = options[:driver] || 'ruby'
|
||||||
# need a connection for Fetcher and Retry
|
# need a connection for Fetcher and Retry
|
||||||
size = options[:size] || (Sidekiq.server? ? (Sidekiq.options[:concurrency] + 2) : 5)
|
size = options[:size] || (Sidekiq.server? ? (Sidekiq.options[:concurrency] + 2) : 5)
|
||||||
|
namespace = options[:namespace] || Sidekiq.options[:namespace]
|
||||||
|
|
||||||
ConnectionPool.new(:timeout => 1, :size => size) do
|
ConnectionPool.new(:timeout => 1, :size => size) do
|
||||||
build_client(url, options[:namespace], driver)
|
build_client(url, namespace, driver)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,36 @@ class TestRedisConnection < MiniTest::Unit::TestCase
|
||||||
|
|
||||||
describe ".create" do
|
describe ".create" do
|
||||||
|
|
||||||
|
it "creates a pooled redis connection" do
|
||||||
|
pool = Sidekiq::RedisConnection.create
|
||||||
|
assert_equal Redis, pool.checkout.class
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "namespace" do
|
||||||
|
|
||||||
|
it "uses a given :namespace" do
|
||||||
|
pool = Sidekiq::RedisConnection.create(:namespace => "xxx")
|
||||||
|
assert_equal "xxx", pool.checkout.namespace
|
||||||
|
end
|
||||||
|
|
||||||
|
it "uses :namespace from Sidekiq.options" do
|
||||||
|
Sidekiq.options = {:namespace => "xxx"}
|
||||||
|
pool = Sidekiq::RedisConnection.create
|
||||||
|
assert_equal "xxx", pool.checkout.namespace
|
||||||
|
end
|
||||||
|
|
||||||
|
it "uses given :namespace over :namespace from Sidekiq.options" do
|
||||||
|
Sidekiq.options = {:namespace => "xxx"}
|
||||||
|
pool = Sidekiq::RedisConnection.create(:namespace => "yyy")
|
||||||
|
assert_equal "yyy", pool.checkout.namespace
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
describe ".determine_redis_provider" do
|
||||||
|
|
||||||
def with_env_var(var, uri, skip_provider=false)
|
def with_env_var(var, uri, skip_provider=false)
|
||||||
vars = ['REDISTOGO_URL', 'REDIS_PROVIDER', 'REDIS_URL'] - [var]
|
vars = ['REDISTOGO_URL', 'REDIS_PROVIDER', 'REDIS_URL'] - [var]
|
||||||
vars.each do |v|
|
vars.each do |v|
|
||||||
|
|
Loading…
Add table
Reference in a new issue