Skip to content

Commit

Permalink
Fix the bug that healthy sentinel displays ERROR on the codis-fe
Browse files Browse the repository at this point in the history
  • Loading branch information
yz1509 committed Feb 9, 2021
1 parent de1ad02 commit 11295b1
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/utils/redis/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ type Client struct {
Pipeline struct {
Send, Recv uint64
}

ExecCmd struct {
Do, Done uint64
}
}

func NewClientNoAuth(addr string, timeout time.Duration) (*Client, error) {
Expand Down Expand Up @@ -61,14 +65,18 @@ func (c *Client) isRecyclable() bool {
return false
case c.Pipeline.Send != c.Pipeline.Recv:
return false
case c.ExecCmd.Do != c.ExecCmd.Done:
return false
case c.Timeout != 0 && c.Timeout <= time.Since(c.LastUse):
return false
}
return true
}

func (c *Client) Do(cmd string, args ...interface{}) (interface{}, error) {
c.ExecCmd.Do++
r, err := c.conn.Do(cmd, args...)
c.ExecCmd.Done++
if err != nil {
c.Close()
return nil, errors.Trace(err)
Expand Down

0 comments on commit 11295b1

Please sign in to comment.