Adding a Status.Peers endpoint to get peerset
This commit is contained in:
parent
5e7e23dc52
commit
3fe3f8815d
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue