Skip to content

Commit

Permalink
have sentinel periodically Ping its master sub connection (might fix m…
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Picciano committed Oct 13, 2016
1 parent 47958ec commit ae13dc6
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions sentinel/sentinel.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,16 +188,25 @@ func NewClientCustom(
}

func (c *Client) subSpin() {
alwaysErr := func(err error) {
select {
case c.alwaysErrCh <- &ClientError{err: err, SentinelErr: true}:
case <-c.closeCh:
}
}

for {
if err := c.subClient.Ping().Err; err != nil {
alwaysErr(err)
return
}

r := c.subClient.Receive()
if r.Timeout() {
continue
}
if r.Err != nil {
select {
case c.alwaysErrCh <- &ClientError{err: r.Err, SentinelErr: true}:
case <-c.closeCh:
}
alwaysErr(r.Err)
return
}
sMsg := strings.Split(r.Message, " ")
Expand Down

0 comments on commit ae13dc6

Please sign in to comment.