FEATURE: allow use of redis sentinel via redis_sentinels

Use: DISCOURSE_REDIS_SENTINELS and DISCOURSE_REDIS_HOST to configure redis
sentinel
This commit is contained in:
Sam
2015-06-25 16:51:48 +10:00
parent 18f887772d
commit 8252f4e110
10 changed files with 30 additions and 90 deletions

View File

@ -6,18 +6,11 @@ class DiscourseRedis
def self.raw_connection(config = nil)
config ||= self.config
redis_opts = {host: config['host'], port: config['port'], db: config['db']}
redis_opts[:password] = config['password'] if config['password']
Redis.new(redis_opts)
Redis.new(config)
end
def self.config
@config ||= YAML.load(ERB.new(File.new("#{Rails.root}/config/redis.yml").read).result)[Rails.env]
end
def self.url(config=nil)
config ||= self.config
"redis://#{(':' + config['password'] + '@') if config['password']}#{config['host']}:#{config['port']}/#{config['db']}"
GlobalSetting.redis_config
end
def initialize(config=nil)
@ -30,10 +23,6 @@ class DiscourseRedis
@redis
end
def url
self.class.url(@config)
end
def self.ignore_readonly
yield
rescue Redis::CommandError => ex