Skip to content

Commit

Permalink
Add leader change event for followers
Browse files Browse the repository at this point in the history
  • Loading branch information
palquel committed Aug 6, 2014
1 parent 73f9c44 commit f98c4b0
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -946,6 +946,10 @@ func (s *server) processAppendEntriesRequest(req *AppendEntriesRequest) (*Append

if req.Term == s.currentTerm {
_assert(s.State() != Leader, "leader.elected.at.same.term.%d\n", s.currentTerm)

if s.leader != req.LeaderName {
s.DispatchEvent(newEvent(LeaderChangeEventType, req.LeaderName, s.leader))
}

// step-down to follower when it is a candidate
if s.state == Candidate {
Expand Down

0 comments on commit f98c4b0

Please sign in to comment.