Skip to content

Commit

Permalink
If the client detects that a heartbeat has failed because it is not r…
Browse files Browse the repository at this point in the history
…egistered, reregister
  • Loading branch information
dadgar committed Aug 16, 2016
1 parent 4764050 commit 134dbb1
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"os"
"path/filepath"
"strconv"
"strings"
"sync"
"sync/atomic"
"time"
Expand Down Expand Up @@ -737,7 +738,17 @@ func (c *Client) registerAndHeartbeat() {
select {
case <-heartbeat:
if err := c.updateNodeStatus(); err != nil {
heartbeat = time.After(c.retryIntv(registerRetryIntv))
// The servers have changed such that this node has not been
// registered before
if strings.Contains(err.Error(), "node not found") {
// Re-register the node
c.logger.Printf("[INFO] client: re-registering node")
c.retryRegisterNode()
heartbeat = time.After(lib.RandomStagger(initialHeartbeatStagger))
} else {
c.logger.Printf("[ERR] client: heartbeating failed: %v", err)
heartbeat = time.After(c.retryIntv(registerRetryIntv))
}
} else {
c.heartbeatLock.Lock()
heartbeat = time.After(c.heartbeatTTL)
Expand Down

0 comments on commit 134dbb1

Please sign in to comment.