mirror of
https://github.com/redis/go-redis.git
synced 2025-07-28 06:42:00 +03:00
Some code improvements
* Rewrite if-else chain as a switch. * Rewrite switch statement with only one case as if. * Remove always true condition. * Simplify some functions.
This commit is contained in:
@ -90,9 +90,7 @@ func NewFailoverClient(failoverOpt *FailoverOptions) *Client {
|
||||
opt: opt,
|
||||
connPool: failover.Pool(),
|
||||
|
||||
onClose: func() error {
|
||||
return failover.Close()
|
||||
},
|
||||
onClose: failover.Close,
|
||||
},
|
||||
}
|
||||
c.baseClient.init()
|
||||
@ -391,8 +389,7 @@ func (c *sentinelFailover) listen(pubsub *PubSub) {
|
||||
break
|
||||
}
|
||||
|
||||
switch msg.Channel {
|
||||
case "+switch-master":
|
||||
if msg.Channel == "+switch-master" {
|
||||
parts := strings.Split(msg.Payload, " ")
|
||||
if parts[0] != c.masterName {
|
||||
internal.Logf("sentinel: ignore addr for master=%q", parts[0])
|
||||
|
Reference in New Issue
Block a user