diff --git a/cmd/revad/internal/grace/grace.go b/cmd/revad/internal/grace/grace.go index 1c6e0ebf029..8aaf18aaf55 100644 --- a/cmd/revad/internal/grace/grace.go +++ b/cmd/revad/internal/grace/grace.go @@ -189,9 +189,6 @@ func (w *Watcher) WritePID() error { } func newListener(network, addr string) (net.Listener, error) { - if network == "dns" { - network = "tcp" - } return net.Listen(network, addr) } diff --git a/pkg/registry/registry.go b/pkg/registry/registry.go index 6658da7c09d..1595726f094 100644 --- a/pkg/registry/registry.go +++ b/pkg/registry/registry.go @@ -44,12 +44,12 @@ func GetRegistry() mRegistry.Registry { } // GetNodeAddress returns a random address from the service nodes -func GetNodeAddress(services []*mRegistry.Service) (string, string, error) { +func GetNodeAddress(services []*mRegistry.Service) (string, error) { next := selector.Random(services) node, err := next() if err != nil { - return "", "", err + return "", err } - return node.Metadata["transport"], node.Address, nil + return node.Address, nil } diff --git a/pkg/rgrpc/todo/pool/selector.go b/pkg/rgrpc/todo/pool/selector.go index 5bc8f329882..69241f204d8 100644 --- a/pkg/rgrpc/todo/pool/selector.go +++ b/pkg/rgrpc/todo/pool/selector.go @@ -20,6 +20,7 @@ package pool import ( "fmt" + "strings" "sync" appProvider "github.com/cs3org/go-cs3apis/cs3/app/provider/v1beta1" @@ -94,22 +95,22 @@ func (s *Selector[T]) Next(opts ...Option) (T, error) { } target := s.id - if options.registry != nil { - services, err := options.registry.GetService(s.id) - if err != nil { - return *new(T), fmt.Errorf("%s: %w", s.id, err) - } - - transport, nodeAddress, err := registry.GetNodeAddress(services) - if err != nil { - return *new(T), fmt.Errorf("%s: %w", s.id, err) - } - switch transport { - case "dns": - target = "dns:///" + nodeAddress - case "unix": - target = transport + ":" + nodeAddress - default: + prefix := strings.SplitN(s.id, ":", 2)[0] + switch prefix { + case "dns", "unix": + // use target as is + default: + // use service registry to look up address + if options.registry != nil { + services, err := options.registry.GetService(s.id) + if err != nil { + return *new(T), fmt.Errorf("%s: %w", s.id, err) + } + + nodeAddress, err := registry.GetNodeAddress(services) + if err != nil { + return *new(T), fmt.Errorf("%s: %w", s.id, err) + } target = nodeAddress } }