1
0
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:
Kirill Motkov
2019-04-17 16:14:30 +03:00
parent 6b2a39a436
commit eca4e5d04c
3 changed files with 8 additions and 13 deletions

View File

@ -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])