diff --git a/consul/endpoints.md b/consul/endpoints.md index 60cf9dd8e7..e885e93498 100644 --- a/consul/endpoints.md +++ b/consul/endpoints.md @@ -24,6 +24,7 @@ from the Consul service. It exposes the following methods: * Ping : Used to test connectivity * Leader : Used to get the address of the leader +* Peers: Used to get the Raft peerset ## Catalog Service diff --git a/consul/status_endpoint.go b/consul/status_endpoint.go index 76233b518d..2908c18d6d 100644 --- a/consul/status_endpoint.go +++ b/consul/status_endpoint.go @@ -20,3 +20,18 @@ func (s *Status) Leader(args struct{}, reply *string) error { } return nil } + +// Peers is used to get all the Raft peers +func (s *Status) Peers(args struct{}, reply *[]string) error { + peers, err := s.server.raftPeers.Peers() + if err != nil { + return err + } + + var peerStrings []string + for _, p := range peers { + peerStrings = append(peerStrings, p.String()) + } + *reply = peerStrings + return nil +}