Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkg/daemon: use grpc.NewClient instead of Dial #4660

Merged
merged 1 commit into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading