File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -201,6 +201,18 @@ func (a *Agent) GetMemberList() []discovery.Member {
201201 return a .membership .Members ()
202202}
203203
204+ // Leader returns the node id of the current Raft leader, or "" if no leader
205+ // is elected (e.g. mid-election or before the cluster has converged).
206+ //
207+ // Exposed for monitoring tooling and external hook authors that need to
208+ // render cluster topology - the dashboard's cluster page in particular.
209+ // Trivial wrapper over raftPeer.GetLeader(), which is otherwise unreachable
210+ // from outside this package.
211+ func (a * Agent ) Leader () string {
212+ _ , id := a .raftPeer .GetLeader ()
213+ return id
214+ }
215+
204216func getRaftPeerAddr (member * discovery.Member ) string {
205217 // using serf
206218 if raftPort , ok := member .Tags [discovery .TagRaftPort ]; ok {
You can’t perform that action at this time.
0 commit comments