mirror of
https://github.com/status-im/consul.git
synced 2025-01-11 14:24:39 +00:00
Straighten control flow in leader.go
This commit is contained in:
parent
2a652b440a
commit
cfd584a784
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user