From da48ce6ded0b7711c74acbc2621acffc8d9f810a Mon Sep 17 00:00:00 2001 From: Chris Sprehe Date: Sun, 24 Nov 2013 08:16:37 -0600 Subject: [PATCH] changed #determine_redis_provider to first check against the REDIS_PROVIDER env variable --- lib/sidekiq/redis_connection.rb | 5 ++--- test/test_redis_connection.rb | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/sidekiq/redis_connection.rb b/lib/sidekiq/redis_connection.rb index 2d0aecef..c5bcfc01 100644 --- a/lib/sidekiq/redis_connection.rb +++ b/lib/sidekiq/redis_connection.rb @@ -11,7 +11,7 @@ module Sidekiq if url options[:url] = url end - + # need a connection for Fetcher and Retry size = options[:size] || (Sidekiq.server? ? (Sidekiq.options[:concurrency] + 2) : 5) pool_timeout = options[:pool_timeout] || 1 @@ -69,9 +69,8 @@ module Sidekiq def determine_redis_provider # REDISTOGO_URL is only support for legacy reasons - return ENV['REDISTOGO_URL'] if ENV['REDISTOGO_URL'] provider = ENV['REDIS_PROVIDER'] || 'REDIS_URL' - ENV[provider] + ENV[provider] || ENV['REDISTOGO_URL'] end end diff --git a/test/test_redis_connection.rb b/test/test_redis_connection.rb index b81f18a3..bebf78a1 100644 --- a/test/test_redis_connection.rb +++ b/test/test_redis_connection.rb @@ -87,6 +87,20 @@ class TestRedisConnection < Sidekiq::Test end end + describe "with REDISTOGO_URL and a parallel REDIS_PROVIDER set" do + it "sets connection URI to the provider" do + uri = 'redis://sidekiq-redis-provider:6379/0' + provider = 'SIDEKIQ_REDIS_PROVIDER' + + ENV['REDIS_PROVIDER'] = provider + ENV[provider] = uri + ENV['REDISTOGO_URL'] = 'redis://redis-to-go:6379/0' + with_env_var provider, uri, true + + ENV[provider] = nil + end + end + describe "with REDIS_PROVIDER set" do it "sets connection URI to the provider" do uri = 'redis://sidekiq-redis-provider:6379/0'