mirror of https://github.com/go-redis/redis.git
commit
3f9b4d7004
|
@ -717,12 +717,12 @@ func (cmd *StringSliceCmd) readReply(rd *proto.Reader) error {
|
||||||
func stringSliceParser(rd *proto.Reader, n int64) (interface{}, error) {
|
func stringSliceParser(rd *proto.Reader, n int64) (interface{}, error) {
|
||||||
ss := make([]string, 0, n)
|
ss := make([]string, 0, n)
|
||||||
for i := int64(0); i < n; i++ {
|
for i := int64(0); i < n; i++ {
|
||||||
s, err := rd.ReadString()
|
switch s, err := rd.ReadString(); {
|
||||||
if err == Nil {
|
case err == Nil:
|
||||||
ss = append(ss, "")
|
ss = append(ss, "")
|
||||||
} else if err != nil {
|
case err != nil:
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
default:
|
||||||
ss = append(ss, s)
|
ss = append(ss, s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
6
redis.go
6
redis.go
|
@ -201,9 +201,7 @@ func (c *baseClient) defaultProcess(cmd Cmder) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = cn.WithReader(c.cmdTimeout(cmd), func(rd *proto.Reader) error {
|
err = cn.WithReader(c.cmdTimeout(cmd), cmd.readReply)
|
||||||
return cmd.readReply(rd)
|
|
||||||
})
|
|
||||||
c.releaseConn(cn, err)
|
c.releaseConn(cn, err)
|
||||||
if err != nil && internal.IsRetryableError(err, cmd.readTimeout() == nil) {
|
if err != nil && internal.IsRetryableError(err, cmd.readTimeout() == nil) {
|
||||||
continue
|
continue
|
||||||
|
@ -237,7 +235,7 @@ func (c *baseClient) cmdTimeout(cmd Cmder) time.Duration {
|
||||||
func (c *baseClient) Close() error {
|
func (c *baseClient) Close() error {
|
||||||
var firstErr error
|
var firstErr error
|
||||||
if c.onClose != nil {
|
if c.onClose != nil {
|
||||||
if err := c.onClose(); err != nil && firstErr == nil {
|
if err := c.onClose(); err != nil {
|
||||||
firstErr = err
|
firstErr = err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,9 +90,7 @@ func NewFailoverClient(failoverOpt *FailoverOptions) *Client {
|
||||||
opt: opt,
|
opt: opt,
|
||||||
connPool: failover.Pool(),
|
connPool: failover.Pool(),
|
||||||
|
|
||||||
onClose: func() error {
|
onClose: failover.Close,
|
||||||
return failover.Close()
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
c.baseClient.init()
|
c.baseClient.init()
|
||||||
|
@ -391,8 +389,7 @@ func (c *sentinelFailover) listen(pubsub *PubSub) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
switch msg.Channel {
|
if msg.Channel == "+switch-master" {
|
||||||
case "+switch-master":
|
|
||||||
parts := strings.Split(msg.Payload, " ")
|
parts := strings.Split(msg.Payload, " ")
|
||||||
if parts[0] != c.masterName {
|
if parts[0] != c.masterName {
|
||||||
internal.Logf("sentinel: ignore addr for master=%q", parts[0])
|
internal.Logf("sentinel: ignore addr for master=%q", parts[0])
|
||||||
|
|
Loading…
Reference in New Issue