From 7b789f58cea7f61ae744488518c1a033724438e9 Mon Sep 17 00:00:00 2001 From: Jamie Scheinblum Date: Thu, 2 Nov 2023 09:39:43 -0700 Subject: [PATCH] Fix address list collection --- go/vt/vtgateproxy/discovery.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/go/vt/vtgateproxy/discovery.go b/go/vt/vtgateproxy/discovery.go index b5b409679b8..06a03a44a2e 100644 --- a/go/vt/vtgateproxy/discovery.go +++ b/go/vt/vtgateproxy/discovery.go @@ -121,8 +121,8 @@ func (r *resolveJSONGateConfig) loadConfig() (*[]resolver.Address, error) { fmt.Printf("%v\n", config) - addrs := make([]resolver.Address, len(config)) - for i, s := range config { + addrs := []resolver.Address{} + for _, s := range config { // Apply filters if r.filters.gate_type != "" { if r.filters.gate_type != s.Type { @@ -138,7 +138,8 @@ func (r *resolveJSONGateConfig) loadConfig() (*[]resolver.Address, error) { } } // Add matching hosts to registration list - addrs[i] = resolver.Address{Addr: fmt.Sprintf("%s:%s", s.Address, s.Grpc)} + fmt.Printf("selected host for discovery: %v %v\n", fmt.Sprintf("%s:%s", s.Address, s.Grpc), s) + addrs = append(addrs, resolver.Address{Addr: fmt.Sprintf("%s:%s", s.Address, s.Grpc)}) } // Shuffle to ensure every host has a different order to iterate through