Straighten control flow in leader.go

This commit is contained in:
Frank Schroeder 2017-05-04 16:15:25 +02:00
parent f3c1f516b4
commit cea98ae5f4
No known key found for this signature in database
GPG Key ID: 4D65C6EAEC87DECD
1 changed files with 13 additions and 13 deletions

View File

@ -93,8 +93,7 @@ RECONCILE:
// Check if we need to handle initial leadership actions
if !establishedLeader {
if err := s.establishLeadership(); err != nil {
s.logger.Printf("[ERR] consul: failed to establish leadership: %v",
err)
s.logger.Printf("[ERR] consul: failed to establish leadership: %v", err)
goto WAIT
}
establishedLeader = true
@ -124,20 +123,21 @@ WAIT:
goto RECONCILE
case member := <-reconcileCh:
s.reconcileMember(member)
case index := <-s.tombstoneGC.ExpireCh():
go s.reapTombstones(index)
case <-s.reassertLeaderCh:
if establishedLeader {
if !establishedLeader {
continue
}
if err := s.revokeLeadership(); err != nil {
s.logger.Printf("[ERR] consul: failed to revoke leadership: %v", err)
goto WAIT
continue
}
if err := s.establishLeadership(); err != nil {
s.logger.Printf("[ERR] consul: failed to re-establish leadership: %v", err)
goto WAIT
continue
}
}
case index := <-s.tombstoneGC.ExpireCh():
go s.reapTombstones(index)
}
}
}