1
0
Fork 0

Fix mutually exclusive verification for Redis

This commit is contained in:
Julien Salleyron 2025-12-22 16:58:04 +01:00 committed by GitHub
parent 1d445d5c9d
commit 278d903bb4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -60,10 +60,20 @@ func (p *Provider) Init() error {
}
if p.Sentinel != nil {
switch {
case p.Sentinel.LatencyStrategy && !(p.Sentinel.RandomStrategy || p.Sentinel.ReplicaStrategy):
case p.Sentinel.RandomStrategy && !(p.Sentinel.LatencyStrategy || p.Sentinel.ReplicaStrategy):
case p.Sentinel.ReplicaStrategy && !(p.Sentinel.RandomStrategy || p.Sentinel.LatencyStrategy):
count := 0
if p.Sentinel.LatencyStrategy {
count++
}
if p.Sentinel.ReplicaStrategy {
count++
}
if p.Sentinel.RandomStrategy {
count++
}
if count > 1 {
return errors.New("latencyStrategy, randomStrategy and replicaStrategy options are mutually exclusive, please use only one of those options")
}