Commit 010dbf6c authored by felipe's avatar felipe Committed by GitHub

feat(proxyd): use a specific redis instance for consensus_ha (#9877)

parent 56f3d1b6
...@@ -123,6 +123,7 @@ type BackendGroupConfig struct { ...@@ -123,6 +123,7 @@ type BackendGroupConfig struct {
ConsensusHA bool `toml:"consensus_ha"` ConsensusHA bool `toml:"consensus_ha"`
ConsensusHAHeartbeatInterval TOMLDuration `toml:"consensus_ha_heartbeat_interval"` ConsensusHAHeartbeatInterval TOMLDuration `toml:"consensus_ha_heartbeat_interval"`
ConsensusHALockPeriod TOMLDuration `toml:"consensus_ha_lock_period"` ConsensusHALockPeriod TOMLDuration `toml:"consensus_ha_lock_period"`
ConsensusHARedis RedisConfig `toml:"consensus_ha_redis"`
} }
type BackendGroupsConfig map[string]*BackendGroupConfig type BackendGroupsConfig map[string]*BackendGroupConfig
......
...@@ -335,8 +335,8 @@ func Start(config *Config) (*Server, func(), error) { ...@@ -335,8 +335,8 @@ func Start(config *Config) (*Server, func(), error) {
var tracker ConsensusTracker var tracker ConsensusTracker
if bgcfg.ConsensusHA { if bgcfg.ConsensusHA {
if redisClient == nil { if bgcfg.ConsensusHARedis.URL == "" {
log.Crit("cant start - consensus high availability requires redis") log.Crit("must specify a consensus_ha_redis config when consensus_ha is true")
} }
topts := make([]RedisConsensusTrackerOpt, 0) topts := make([]RedisConsensusTrackerOpt, 0)
if bgcfg.ConsensusHALockPeriod > 0 { if bgcfg.ConsensusHALockPeriod > 0 {
...@@ -345,7 +345,11 @@ func Start(config *Config) (*Server, func(), error) { ...@@ -345,7 +345,11 @@ func Start(config *Config) (*Server, func(), error) {
if bgcfg.ConsensusHAHeartbeatInterval > 0 { if bgcfg.ConsensusHAHeartbeatInterval > 0 {
topts = append(topts, WithLockPeriod(time.Duration(bgcfg.ConsensusHAHeartbeatInterval))) topts = append(topts, WithLockPeriod(time.Duration(bgcfg.ConsensusHAHeartbeatInterval)))
} }
tracker = NewRedisConsensusTracker(context.Background(), redisClient, bg, bg.Name, topts...) consensusHARedisClient, err := NewRedisClient(bgcfg.ConsensusHARedis.URL)
if err != nil {
return nil, nil, err
}
tracker = NewRedisConsensusTracker(context.Background(), consensusHARedisClient, bg, bg.Name, topts...)
copts = append(copts, WithTracker(tracker)) copts = append(copts, WithTracker(tracker))
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment