Skip to content

Commit

Permalink
Unpin grpc version and use serviceConfig to set the load balancer (#1786
Browse files Browse the repository at this point in the history
)

* Unpin grpc version and use serviceConfig to set loadbalancer (WIP)

Signed-off-by: Jude Wang <judew@uber.com>

* Undo idl change

Signed-off-by: Yuri Shkuro <ys@uber.com>
  • Loading branch information
guanw authored and yurishkuro committed Sep 12, 2019
1 parent 865f169 commit 3fa1dfa
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 46 deletions.
82 changes: 41 additions & 41 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ required = [

[[constraint]]
name = "google.golang.org/grpc"
version = "=1.20.1"
version = "^1.20.1"

[[constraint]]
name = "github.com/olivere/elastic"
Expand Down
3 changes: 1 addition & 2 deletions cmd/agent/app/reporter/grpc/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
grpc_retry "github.com/grpc-ecosystem/go-grpc-middleware/retry"
"go.uber.org/zap"
"google.golang.org/grpc"
"google.golang.org/grpc/balancer/roundrobin"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/resolver"
"google.golang.org/grpc/resolver/manual"
Expand Down Expand Up @@ -130,7 +129,7 @@ func (b *ConnBuilder) CreateConnection(logger *zap.Logger) (*grpc.ClientConn, er
dialTarget = b.CollectorHostPorts[0]
}
}
dialOptions = append(dialOptions, grpc.WithBalancerName(roundrobin.Name))
dialOptions = append(dialOptions, grpc.WithDefaultServiceConfig(grpcresolver.GRPCServiceConfig))
dialOptions = append(dialOptions, grpc.WithUnaryInterceptor(grpc_retry.UnaryClientInterceptor(grpc_retry.WithMax(b.MaxRetry))))
return grpc.Dial(dialTarget, dialOptions...)
}
3 changes: 3 additions & 0 deletions pkg/discovery/grpcresolver/grpc_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ import (
"github.com/jaegertracing/jaeger/pkg/discovery"
)

// GRPCServiceConfig provides grpc service config
const GRPCServiceConfig = `{"loadBalancingPolicy":"round_robin"}`

// Resolver uses notifier to fetch list of available hosts
type Resolver struct {
scheme string
Expand Down
3 changes: 1 addition & 2 deletions pkg/discovery/grpcresolver/grpc_resolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"github.com/stretchr/testify/assert"
"go.uber.org/zap"
"google.golang.org/grpc"
"google.golang.org/grpc/balancer/roundrobin"
"google.golang.org/grpc/peer"
"google.golang.org/grpc/resolver"
grpctest "google.golang.org/grpc/test/grpc_testing"
Expand Down Expand Up @@ -143,7 +142,7 @@ func TestGRPCResolverRoundRobin(t *testing.T) {
res := New(notifier, discoverer, zap.NewNop(), test.minPeers)
defer resolver.UnregisterForTesting(res.Scheme())

cc, err := grpc.Dial(res.Scheme()+":///round_robin", grpc.WithInsecure(), grpc.WithBalancerName(roundrobin.Name))
cc, err := grpc.Dial(res.Scheme()+":///round_robin", grpc.WithInsecure(), grpc.WithDefaultServiceConfig(GRPCServiceConfig))
assert.NoError(t, err, "could not dial using resolver's scheme")
defer cc.Close()

Expand Down

0 comments on commit 3fa1dfa

Please sign in to comment.