mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
Validate REDIS_PROVIDER, fixes #3969
This commit is contained in:
parent
fe323f988c
commit
0429ce9d02
2 changed files with 20 additions and 15 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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'
|
||||
|
|
Loading…
Add table
Reference in a new issue