func (i *AgentIPC) handleMembers(client *IPCClient, seq uint64) error { serf := i.agent.Serf() raw := serf.Members() members := make([]Member, 0, len(raw)) for _, m := range raw { sm := Member{ Name: m.Name, Addr: m.Addr, Port: m.Port, Role: m.Role, Status: m.Status.String(), ProtocolMin: m.ProtocolMin, ProtocolMax: m.ProtocolMax, ProtocolCur: m.ProtocolCur, DelegateMin: m.DelegateMin, DelegateMax: m.DelegateMax, DelegateCur: m.DelegateCur, } members = append(members, sm) } header := responseHeader{ Seq: seq, Error: "", } resp := membersResponse{ Members: members, } return client.Send(&header, &resp) }
func (i *AgentIPC) handleMembers(client *IPCClient, command string, seq uint64) error { serf := i.agent.Serf() raw := serf.Members() members := make([]Member, 0, len(raw)) if command == membersFilteredCommand { var req membersFilteredRequest err := client.dec.Decode(&req) if err != nil { return fmt.Errorf("decode failed: %v", err) } raw, err = i.filterMembers(raw, req.Tags, req.Status, req.Name) if err != nil { return err } } for _, m := range raw { sm := Member{ Name: m.Name, Addr: m.Addr, Port: m.Port, Tags: m.Tags, Status: m.Status.String(), ProtocolMin: m.ProtocolMin, ProtocolMax: m.ProtocolMax, ProtocolCur: m.ProtocolCur, DelegateMin: m.DelegateMin, DelegateMax: m.DelegateMax, DelegateCur: m.DelegateCur, } members = append(members, sm) } header := responseHeader{ Seq: seq, Error: "", } resp := membersResponse{ Members: members, } return client.Send(&header, &resp) }