Straighten control flow in leader.go

This commit is contained in:
Frank Schroeder 2017-05-04 16:15:25 +02:00
parent 2a652b440a
commit cfd584a784
No known key found for this signature in database
GPG Key ID: 4D65C6EAEC87DECD

View File

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