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

feat(transport/grpc,contrib): add NewClient method to gRPC client(#3312) #3323

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

fengyuwusong
Copy link
Contributor

Description (what this PR does / why we need it):

  • because the gRPC 1.63 x and subsequent versions plan to abolish the Dial method, so implement NewClient, NewClientInsecure method, annotation and abandoned the original Dial, DialInsecure method
  • the change to adjust relevant test cases as well as the method of document

Which issue(s) this PR fixes (resolves / be part of):

resolves: #3312

Other special notes for the reviewers:

…kratos#3312)

* feat: update grpc v1.63.x

* feat: use NewClient method replace Dial in gRPC client

* test: update grpc client test case

* docs: update README.md
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label May 17, 2024
@fengyuwusong
Copy link
Contributor Author

please review this pr,thanks~

}

// Deprecated: use newClient instead.
func dial(ctx context.Context, options clientOptions, grpcOpts []grpc.DialOption) (*grpc.ClientConn, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this still kept

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Internal methods will not affect external compatibility

dialCtx, cancel := context.WithTimeout(dialCtx, time.Second)
defer cancel()
conn, err := grpc.DialContext(dialCtx, opt.Endpoint, grpc.WithTransportCredentials(insecure.NewCredentials()))
conn, err := grpc.NewClient(opt.Endpoint, grpc.WithTransportCredentials(insecure.NewCredentials()))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How to control dial timeout

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Add NewClient method to gRPC Client
3 participants