Change ByID boolean to Peer string and add Peer id in replicas output

The CLI will now be able to display the peer IDs in MetaGroupInfo
if it choses to do so, and possibly help user select the peer ID
from a list with a new command to remove by peer ID instead of
by server name.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
This commit is contained in:
Ivan Kozlovic
2022-09-15 10:36:22 -06:00
parent e1f0361b98
commit f113163b9f
5 changed files with 24 additions and 15 deletions

View File

@@ -581,7 +581,9 @@ const JSApiLeaderStepDownResponseType = "io.nats.jetstream.api.v1.meta_leader_st
type JSApiMetaServerRemoveRequest struct {
// Server name of the peer to be removed.
Server string `json:"peer"`
ByID bool `json:"by_id,omitempty"`
// Peer ID of the peer to be removed. If specified this is used
// instead of the server name.
Peer string `json:"peer_id,omitempty"`
}
// JSApiMetaServerRemoveResponse is the response to a peer removal request in the meta group.
@@ -2216,9 +2218,10 @@ func (s *Server) jsLeaderServerRemoveRequest(sub *subscription, c *client, _ *Ac
var found string
js.mu.RLock()
for _, p := range cc.meta.Peers() {
if req.ByID {
if p.ID == req.Server {
found = req.Server
// If Peer is specified, it takes precedence
if req.Peer != _EMPTY_ {
if p.ID == req.Peer {
found = req.Peer
break
}
continue