Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/redis/wrapper.rb')
-rw-r--r--lib/gitlab/redis/wrapper.rb45
1 files changed, 17 insertions, 28 deletions
diff --git a/lib/gitlab/redis/wrapper.rb b/lib/gitlab/redis/wrapper.rb
index 0e5389dc995..e5e1e1d4165 100644
--- a/lib/gitlab/redis/wrapper.rb
+++ b/lib/gitlab/redis/wrapper.rb
@@ -41,21 +41,6 @@ module Gitlab
size
end
- def _raw_config
- return @_raw_config if defined?(@_raw_config)
-
- @_raw_config =
- begin
- if filename = config_file_name
- ERB.new(File.read(filename)).result.freeze
- else
- false
- end
- rescue Errno::ENOENT
- false
- end
- end
-
def config_file_path(filename)
path = File.join(rails_root, 'config', filename)
return path if File.file?(path)
@@ -67,10 +52,6 @@ module Gitlab
File.expand_path('../../..', __dir__)
end
- def config_fallback?
- config_file_name == config_fallback&.config_file_name
- end
-
def config_file_name
[
# Instance specific config sources:
@@ -91,6 +72,10 @@ module Gitlab
].compact.first
end
+ def redis_yml_path
+ File.join(rails_root, 'config/redis.yml')
+ end
+
def store_name
name.demodulize
end
@@ -212,16 +197,20 @@ module Gitlab
end
def fetch_config
- return false unless self.class._raw_config
-
- yaml = YAML.safe_load(self.class._raw_config, aliases: true)
+ redis_yml = read_yaml(self.class.redis_yml_path).fetch(@rails_env, {})
+ instance_config_yml = read_yaml(self.class.config_file_name)[@rails_env]
+
+ [
+ redis_yml[self.class.store_name.underscore],
+ instance_config_yml,
+ self.class.config_fallback && redis_yml[self.class.config_fallback.store_name.underscore]
+ ].compact.first
+ end
- # If the file has content but it's invalid YAML, `load` returns false
- if yaml
- yaml.fetch(@rails_env, false)
- else
- false
- end
+ def read_yaml(path)
+ YAML.safe_load(ERB.new(File.read(path.to_s)).result, aliases: true) || {}
+ rescue Errno::ENOENT
+ {}
end
end
end