From 0213e033ee698093933d8317a6f2c0ebd9ac0d81 Mon Sep 17 00:00:00 2001 From: apesternikov Date: Wed, 15 Jun 2022 13:54:11 -0700 Subject: [PATCH] address WithBalancerName deleted in grpc v1.46.0 (#324) * upgrade grpc to v1.47.0 & address deleted WithBalancerName that was deprecated for 2 years https://github.com/grpc/grpc-go/pull/5232 * restore go.mod and go.sum --- mainboilerplate/client.go | 6 ++++-- server/server.go | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/mainboilerplate/client.go b/mainboilerplate/client.go index 3c053182..94e62ec1 100644 --- a/mainboilerplate/client.go +++ b/mainboilerplate/client.go @@ -2,6 +2,7 @@ package mainboilerplate import ( "context" + "fmt" "time" grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus" @@ -9,6 +10,7 @@ import ( pb "go.gazette.dev/core/broker/protocol" pc "go.gazette.dev/core/consumer/protocol" "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" ) // AddressConfig of a remote service. @@ -20,8 +22,8 @@ type AddressConfig struct { func (c *AddressConfig) MustDial(ctx context.Context) *grpc.ClientConn { var cc, err = grpc.DialContext(ctx, c.Address.GRPCAddr(), - grpc.WithInsecure(), - grpc.WithBalancerName(pb.DispatcherGRPCBalancerName), + grpc.WithTransportCredentials(insecure.NewCredentials()), + grpc.WithDefaultServiceConfig(fmt.Sprintf(`{"loadBalancingConfig": [{"%s":{}}]}`, pb.DispatcherGRPCBalancerName)), // Use a tighter bound for the maximum back-off delay (default is 120s). // TODO(johnny): Make this configurable? grpc.WithBackoffMaxDelay(time.Second*5), diff --git a/server/server.go b/server/server.go index ef3e84cd..5885c8f5 100644 --- a/server/server.go +++ b/server/server.go @@ -15,6 +15,7 @@ import ( pb "go.gazette.dev/core/broker/protocol" "go.gazette.dev/core/task" "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" ) // Server bundles gRPC & HTTP servers, multiplexed over a single bound TCP @@ -91,8 +92,8 @@ func New(iface string, port string) (*Server, error) { srv.GRPCLoopback, err = grpc.DialContext( context.Background(), srv.RawListener.Addr().String(), - grpc.WithInsecure(), - grpc.WithBalancerName(pb.DispatcherGRPCBalancerName), + grpc.WithTransportCredentials(insecure.NewCredentials()), + grpc.WithDefaultServiceConfig(fmt.Sprintf(`{"loadBalancingConfig": [{"%s":{}}]}`, pb.DispatcherGRPCBalancerName)), // This grpc.ClientConn connects to this server's loopback, and also // to peer server addresses via the dispatch balancer. It has particular // knowledge of what addresses *should* be reach-able (from Etcd