Skip to content

Commit

Permalink
address WithBalancerName deleted in grpc v1.46.0 (gazette#324)
Browse files Browse the repository at this point in the history
* upgrade grpc to v1.47.0 & address deleted WithBalancerName that was deprecated for 2 years grpc/grpc-go#5232

* restore go.mod and go.sum
  • Loading branch information
apesternikov authored and michaelschiff committed Jun 16, 2022
1 parent 25a2abe commit 1ac4103
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 4 additions & 2 deletions mainboilerplate/client.go
Expand Up @@ -2,13 +2,15 @@ package mainboilerplate

import (
"context"
"fmt"
"time"

grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
"go.gazette.dev/core/broker/client"
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.
Expand All @@ -19,8 +21,8 @@ type AddressConfig struct {
// MustDial dials the server address using a protocol.Dispatcher balancer, and panics on error.
func (c *AddressConfig) MustDial(ctx context.Context) *grpc.ClientConn {
var cc, err = grpc.DialContext(ctx, c.Address.URL().Host,
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),
Expand Down
5 changes: 3 additions & 2 deletions server/server.go
Expand Up @@ -14,6 +14,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
Expand Down Expand Up @@ -83,8 +84,8 @@ func New(iface string, port uint16) (*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
Expand Down

0 comments on commit 1ac4103

Please sign in to comment.