FEATURE: AR adapter to failover to a replica DB server.

This commit is contained in:
Guo Xiang Tan
2016-01-25 14:27:59 +08:00
parent 0ef141b2c3
commit 46589a1a0c
5 changed files with 208 additions and 2 deletions

View File

@ -18,11 +18,14 @@ class GlobalSetting
def self.database_config
hash = {"adapter" => "postgresql"}
%w{pool timeout socket host port username password}.each do |s|
%w{pool timeout socket host port username password replica_host replica_port}.each do |s|
if val = self.send("db_#{s}")
hash[s] = val
end
end
hash["adapter"] = "postgresql_fallback" if hash["replica_host"]
hostnames = [ hostname ]
hostnames << backup_hostname if backup_hostname.present?