This commit is contained in:
Ian Gulliver
2026-10-21 08:52:31 -07:00
parent 6a949dc448
commit 485acc1bf9
3 changed files with 16 additions and 31 deletions
+7 -5
View File
@@ -206,8 +206,7 @@ func (r *Registry) List() []Client {
func (r *Registry) Call(ctx context.Context, name string, req api.ClientRequest) (api.ClientReply, error) {
r.mu.Lock()
matches := []*conn{}
matched := []string{}
matches := []entry{}
connected := []string{}
for _, e := range r.clients {
if e.conn == nil {
@@ -215,8 +214,7 @@ func (r *Registry) Call(ctx context.Context, name string, req api.ClientRequest)
}
connected = append(connected, fmt.Sprintf("%s (%s)", e.Host, e.ID))
if e.ID == name || e.Host == name {
matches = append(matches, e.conn)
matched = append(matched, e.ID)
matches = append(matches, *e)
}
}
r.mu.Unlock()
@@ -225,10 +223,14 @@ func (r *Registry) Call(ctx context.Context, name string, req api.ClientRequest)
return api.ClientReply{}, fmt.Errorf("no client named %q is connected; connected: %s", name, strings.Join(connected, ", "))
}
if len(matches) > 1 {
matched := make([]string, len(matches))
for i, e := range matches {
matched[i] = e.ID
}
slices.Sort(matched)
return api.ClientReply{}, fmt.Errorf("%d clients on %s are connected; name one by its id: %s", len(matches), name, strings.Join(matched, ", "))
}
c := matches[0]
c := matches[0].conn
req.Id = ids.New(ids.ClientRequest)
ch := make(chan api.ClientReply, 1)