Skip to content
This repository has been archived by the owner on Aug 23, 2023. It is now read-only.

Commit

Permalink
only update primary/state if they have changed. fixes #430
Browse files Browse the repository at this point in the history
  • Loading branch information
woodsaj committed Jan 13, 2017
1 parent 2a0f641 commit 05be03c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cluster/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ func (c *ClusterManager) IsReady() bool {

func (c *ClusterManager) SetReady() {
c.Lock()
if c.node.State == NodeReady {
c.Unlock()
return
}
c.node.State = NodeReady
c.node.Updated = time.Now()
c.Unlock()
Expand All @@ -198,6 +202,10 @@ func (c *ClusterManager) IsPrimary() bool {
// Note: since we set the primary metric here, this should only be called on ThisNode !
func (c *ClusterManager) SetPrimary(p bool) {
c.Lock()
if c.node.Primary == p {
c.Unlock()
return
}
c.node.Primary = p
c.node.PrimaryChange = time.Now()
c.node.Updated = time.Now()
Expand Down

0 comments on commit 05be03c

Please sign in to comment.