Fix mutually exclusive verification for Redis
This commit is contained in:
parent
1d445d5c9d
commit
278d903bb4
1 changed files with 14 additions and 4 deletions
|
|
@ -60,10 +60,20 @@ func (p *Provider) Init() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if p.Sentinel != nil {
|
if p.Sentinel != nil {
|
||||||
switch {
|
count := 0
|
||||||
case p.Sentinel.LatencyStrategy && !(p.Sentinel.RandomStrategy || p.Sentinel.ReplicaStrategy):
|
if p.Sentinel.LatencyStrategy {
|
||||||
case p.Sentinel.RandomStrategy && !(p.Sentinel.LatencyStrategy || p.Sentinel.ReplicaStrategy):
|
count++
|
||||||
case p.Sentinel.ReplicaStrategy && !(p.Sentinel.RandomStrategy || p.Sentinel.LatencyStrategy):
|
}
|
||||||
|
|
||||||
|
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")
|
return errors.New("latencyStrategy, randomStrategy and replicaStrategy options are mutually exclusive, please use only one of those options")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue