From e33977e7f3fcd6acaa72fa06555c58e60382cf3b Mon Sep 17 00:00:00 2001
From: Pavol Loffay
Date: Fri, 11 Jun 2021 20:24:45 +0200
Subject: [PATCH] Use withResolver API in gRPC reporter (#3078)
* Use withResolver API in gRPC reporter
Signed-off-by: Pavol Loffay
* Use manual
Signed-off-by: Pavol Loffay
* fmt
Signed-off-by: Pavol Loffay
---
cmd/agent/app/reporter/grpc/builder.go | 14 ++------------
1 file changed, 2 insertions(+), 12 deletions(-)
diff --git a/cmd/agent/app/reporter/grpc/builder.go b/cmd/agent/app/reporter/grpc/builder.go
index e228293ab31..58e83fdd449 100644
--- a/cmd/agent/app/reporter/grpc/builder.go
+++ b/cmd/agent/app/reporter/grpc/builder.go
@@ -18,9 +18,7 @@ import (
"context"
"errors"
"fmt"
- "strconv"
"strings"
- "time"
grpc_retry "github.com/grpc-ecosystem/go-grpc-middleware/retry"
"github.com/uber/jaeger-lib/metrics"
@@ -82,7 +80,8 @@ func (b *ConnBuilder) CreateConnection(logger *zap.Logger, mFactory metrics.Fact
return nil, errors.New("at least one collector hostPort address is required when resolver is not available")
}
if len(b.CollectorHostPorts) > 1 {
- r, _ := generateAndRegisterManualResolver()
+ r := manual.NewBuilderWithScheme("jaeger_manual")
+ dialOptions = append(dialOptions, grpc.WithResolvers(r))
var resolvedAddrs []resolver.Address
for _, addr := range b.CollectorHostPorts {
resolvedAddrs = append(resolvedAddrs, resolver.Address{Addr: addr})
@@ -125,12 +124,3 @@ func (b *ConnBuilder) CreateConnection(logger *zap.Logger, mFactory metrics.Fact
return conn, nil
}
-
-// generateAndRegisterManualResolver was removed from grpc.
-// Copied here to keep behavior the same.
-func generateAndRegisterManualResolver() (*manual.Resolver, func()) {
- scheme := strconv.FormatInt(time.Now().UnixNano(), 36)
- r := manual.NewBuilderWithScheme(scheme)
- resolver.Register(r)
- return r, func() { resolver.UnregisterForTesting(scheme) }
-}