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

@@ -31,6 +31,25 @@ class GlobalSetting
{"production" => hash}
end
def self.redis_config
@config ||=
begin
c = {}
c[:host] = redis_host if redis_host
c[:port] = redis_port if redis_port
c[:password] = redis_host if redis_password.present?
c[:db] = redis_db if redis_db != 0
c[:db] = 1 if Rails.env == "test"
if redis_sentinels.present?
c[:sentinels] = redis_sentinels.split(",").map do |address|
host,port = address.split(":")
{host: host, port: port}
end.to_a
end
c.freeze
end
end
class BaseProvider
def self.coerce(setting)