Skip to content

Commit

Permalink
pkg/daemon: use grpc.NewClient instead of Dial (#4660)
Browse files Browse the repository at this point in the history
Dial and DialContext is deprecated in newer version of gRPC. (See
https://pkg.go.dev/google.golang.org/grpc#Dial)
  • Loading branch information
lukedirtwalker authored Dec 24, 2024
1 parent ca52e4f commit efbbd58
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions pkg/daemon/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ go_library(
"//pkg/snet/path:go_default_library",
"//private/topology:go_default_library",
"@org_golang_google_grpc//:go_default_library",
"@org_golang_google_grpc//credentials/insecure:go_default_library",
"@org_golang_google_protobuf//types/known/emptypb:go_default_library",
"@org_golang_google_protobuf//types/known/timestamppb:go_default_library",
],
Expand Down
14 changes: 7 additions & 7 deletions pkg/daemon/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"time"

"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/protobuf/types/known/emptypb"
"google.golang.org/protobuf/types/known/timestamppb"

Expand Down Expand Up @@ -48,15 +49,14 @@ type Service struct {
}

func (s Service) Connect(ctx context.Context) (Connector, error) {
a, err := net.ResolveTCPAddr("tcp", s.Address)
conn, err := grpc.NewClient(s.Address,
grpc.WithTransportCredentials(insecure.NewCredentials()),
libgrpc.UnaryClientInterceptor(),
libgrpc.StreamClientInterceptor(),
)
if err != nil {
s.Metrics.incConnects(err)
return nil, serrors.Wrap("resolving addr", err)
}
conn, err := libgrpc.SimpleDialer{}.Dial(ctx, a)
if err != nil {
s.Metrics.incConnects(err)
return nil, serrors.Wrap("dialing", err)
return nil, serrors.Wrap("creating client", err)
}
s.Metrics.incConnects(nil)
return grpcConn{conn: conn, metrics: s.Metrics}, nil
Expand Down

0 comments on commit efbbd58

Please sign in to comment.