rc.log.Error("failed to demote voter","id",id,"err",err)
returnerr
}
returnnil
}
// Leader implements Consensus, it returns true if it is the leader of the cluster.
func(rc*RaftConsensus)Leader()bool{
_,id:=rc.r.LeaderWithID()
returnid==rc.serverID
}
// LeaderCh implements Consensus, it returns a channel that will be notified when leadership status changes (true = leader, false = follower).
func(rc*RaftConsensus)LeaderCh()<-chanbool{
returnrc.r.LeaderCh()
}
// RemoveServer implements Consensus, it tries to remove a member (both voter or non-voter) from the cluster, if leader is being removed, it will cause a new leader election.