Watching for node updates after registration completes
This commit is contained in:
parent
8c7c48b01a
commit
57b0bbcb8b
|
@ -697,6 +697,9 @@ func (c *Client) registerAndHeartbeat() {
|
||||||
// Register the node
|
// Register the node
|
||||||
c.retryRegisterNode()
|
c.retryRegisterNode()
|
||||||
|
|
||||||
|
// Start watching changes for node changes
|
||||||
|
go c.watchNodeUpdates()
|
||||||
|
|
||||||
// Setup the heartbeat timer, for the initial registration
|
// Setup the heartbeat timer, for the initial registration
|
||||||
// we want to do this quickly. We want to do it extra quickly
|
// we want to do this quickly. We want to do it extra quickly
|
||||||
// in development mode.
|
// in development mode.
|
||||||
|
@ -746,9 +749,6 @@ func (c *Client) periodicSnapshot() {
|
||||||
|
|
||||||
// run is a long lived goroutine used to run the client
|
// run is a long lived goroutine used to run the client
|
||||||
func (c *Client) run() {
|
func (c *Client) run() {
|
||||||
// Watch for node changes
|
|
||||||
go c.watchNodeUpdates()
|
|
||||||
|
|
||||||
// Watch for changes in allocations
|
// Watch for changes in allocations
|
||||||
allocUpdates := make(chan *allocUpdates, 8)
|
allocUpdates := make(chan *allocUpdates, 8)
|
||||||
go c.watchAllocations(allocUpdates)
|
go c.watchAllocations(allocUpdates)
|
||||||
|
@ -1062,7 +1062,7 @@ func (c *Client) watchNodeUpdates() {
|
||||||
var changed bool
|
var changed bool
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-time.After(nodeUpdateRetryIntv):
|
case <-time.After(c.retryIntv(nodeUpdateRetryIntv)):
|
||||||
changed, attrHash, metaHash = c.hasNodeChanged(attrHash, metaHash)
|
changed, attrHash, metaHash = c.hasNodeChanged(attrHash, metaHash)
|
||||||
if changed {
|
if changed {
|
||||||
c.logger.Printf("[DEBUG] client: state changed, updating node.")
|
c.logger.Printf("[DEBUG] client: state changed, updating node.")
|
||||||
|
|
Loading…
Reference in a new issue