Skip to content

Commit

Permalink
Polish
Browse files Browse the repository at this point in the history
Signed-off-by: Pavol Loffay <ploffay@redhat.com>
  • Loading branch information
pavolloffay committed Feb 26, 2019
1 parent bc8f712 commit bfbf3bc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
14 changes: 8 additions & 6 deletions cmd/agent/app/reporter/grpc/collector_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,23 @@ func NewCollectorProxy(o *Options, mFactory metrics.Factory, logger *zap.Logger)
if len(o.CollectorHostPort) == 0 {
return nil, errors.New("could not create collector proxy, address is missing")
}
var conn *grpc.ClientConn
var target string
if len(o.CollectorHostPort) > 1 {
r, _ := manual.GenerateAndRegisterManualResolver()
var resolvedAddrs []resolver.Address
for _, addr := range o.CollectorHostPort {
resolvedAddrs = append(resolvedAddrs, resolver.Address{Addr: addr})
}
r.InitialAddrs(resolvedAddrs)
conn, _ = grpc.Dial(r.Scheme()+":///round_robin", grpc.WithInsecure(), grpc.WithBalancerName(roundrobin.Name),
grpc.WithUnaryInterceptor(grpc_retry.UnaryClientInterceptor(grpc_retry.WithMax(o.MaxRetry))))
target = r.Scheme() + ":///round_robin"
} else {
// It does not return error if the collector is not running
conn, _ = grpc.Dial(o.CollectorHostPort[0], grpc.WithInsecure(), grpc.WithBalancerName(roundrobin.Name),
grpc.WithUnaryInterceptor(grpc_retry.UnaryClientInterceptor(grpc_retry.WithMax(o.MaxRetry))))
target = o.CollectorHostPort[0]
}
// It does not return error if the collector is not running
conn, _ := grpc.Dial(target,
grpc.WithInsecure(),
grpc.WithBalancerName(roundrobin.Name),
grpc.WithUnaryInterceptor(grpc_retry.UnaryClientInterceptor(grpc_retry.WithMax(o.MaxRetry))))
grpcMetrics := mFactory.Namespace(metrics.NSOptions{Name: "", Tags: map[string]string{"protocol": "grpc"}})
return &ProxyBuilder{
conn: conn,
Expand Down
1 change: 1 addition & 0 deletions cmd/agent/app/reporter/grpc/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const (
gRPCPrefix = "reporter.grpc."
collectorHostPort = gRPCPrefix + "host-port"
retry = gRPCPrefix + "retry.max"
defaultMaxRetry = 3
)

// Options Struct to hold configurations
Expand Down
4 changes: 0 additions & 4 deletions cmd/agent/app/reporter/grpc/reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ import (
"github.com/jaegertracing/jaeger/thrift-gen/zipkincore"
)

const (
defaultMaxRetry = 3
)

// Reporter reports data to collector over gRPC.
type Reporter struct {
collector api_v2.CollectorServiceClient
Expand Down

0 comments on commit bfbf3bc

Please sign in to comment.