diff options
Diffstat (limited to 'lib/gitlab/redis/wrapper.rb')
-rw-r--r-- | lib/gitlab/redis/wrapper.rb | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/lib/gitlab/redis/wrapper.rb b/lib/gitlab/redis/wrapper.rb index 3c8ac07215d..7b804038146 100644 --- a/lib/gitlab/redis/wrapper.rb +++ b/lib/gitlab/redis/wrapper.rb @@ -6,6 +6,7 @@ # Rails. require 'active_support/core_ext/hash/keys' require 'active_support/core_ext/module/delegation' +require 'active_support/core_ext/object/blank' require 'active_support/core_ext/string/inflections' # Explicitly load Redis::Store::Factory so we can read Redis configuration in @@ -95,6 +96,8 @@ module Gitlab end def instrumentation_class + return unless defined?(::Gitlab::Instrumentation::Redis) + "::Gitlab::Instrumentation::Redis::#{store_name}".constantize end end @@ -111,6 +114,10 @@ module Gitlab raw_config_hash[:url] end + def db + redis_store_options[:db] + end + def sentinels raw_config_hash[:sentinels] end @@ -150,11 +157,35 @@ module Gitlab def raw_config_hash config_data = fetch_config - if config_data - config_data.is_a?(String) ? { url: config_data } : config_data.deep_symbolize_keys - else - { url: '' } + config_hash = + if config_data + config_data.is_a?(String) ? { url: config_data } : config_data.deep_symbolize_keys + else + { url: '' } + end + + if config_hash[:url].blank? + config_hash[:url] = legacy_fallback_urls[self.class.store_name] || legacy_fallback_urls[self.class.config_fallback.store_name] end + + config_hash + end + + # These URLs were defined for cache, queues, and shared_state in + # code. They are used only when no config file exists at all for a + # given instance. The configuration does not seem particularly + # useful - it uses different ports on localhost - but we cannot + # confidently delete it as we don't know if any instances rely on + # this. + # + # DO NOT ADD new instances here. All new instances should define a + # `.config_fallback`, which will then be used to look up this URL. + def legacy_fallback_urls + { + 'Cache' => 'redis://localhost:6380', + 'Queues' => 'redis://localhost:6381', + 'SharedState' => 'redis://localhost:6382' + } end def fetch_config |