diff --git a/lib/sidekiq/redis_connection.rb b/lib/sidekiq/redis_connection.rb index 4d5664d5..064c2137 100644 --- a/lib/sidekiq/redis_connection.rb +++ b/lib/sidekiq/redis_connection.rb @@ -115,27 +115,20 @@ module Sidekiq # REDIS_PROVIDER=MY_REDIS_URL # and Sidekiq will find your custom URL variable with no custom # initialization code at all. + # p = ENV['REDIS_PROVIDER'] if p && p =~ /\:/ - Sidekiq.logger.error <<-EOM + raise <<-EOM +REDIS_PROVIDER should be set to the name of the variable which contains the Redis URL, not a URL itself. +Platforms like Heroku will sell addons that publish a *_URL variable. You need to tell Sidekiq with REDIS_PROVIDER, e.g.: -################################################################################# - -REDIS_PROVIDER should be set to the **name** of the variable which contains the Redis URL, not a URL itself. -Platforms like Heroku sell addons that publish a *_URL variable. You tell Sidekiq with REDIS_PROVIDER, e.g.: - - REDIS_PROVIDER=REDISTOGO_URL - REDISTOGO_URL=redis://somehost.example.com:6379/4 - -Use REDIS_URL if you wish to point Sidekiq to a URL directly. - -This configuration error will crash starting in Sidekiq 5.3. - -################################################################################# +REDIS_PROVIDER=REDISTOGO_URL +REDISTOGO_URL=redis://somehost.example.com:6379/4 EOM end + ENV[ - ENV['REDIS_PROVIDER'] || 'REDIS_URL' + p || 'REDIS_URL' ] end diff --git a/test/test_redis_connection.rb b/test/test_redis_connection.rb index 2af17676..0110144b 100644 --- a/test/test_redis_connection.rb +++ b/test/test_redis_connection.rb @@ -223,6 +223,18 @@ class TestRedisConnection < Minitest::Test end describe "with REDIS_PROVIDER set" do + it "rejects URLs in REDIS_PROVIDER" do + uri = 'redis://sidekiq-redis-provider:6379/0' + + ENV['REDIS_PROVIDER'] = uri + + #assert_raises RuntimeError do + Sidekiq::RedisConnection.__send__(:determine_redis_provider) + #end + + ENV['REDIS_PROVIDER'] = nil + end + it "sets connection URI to the provider" do uri = 'redis://sidekiq-redis-provider:6379/0' provider = 'SIDEKIQ_REDIS_PROVIDER'