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 1 commit 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
func Dial(ctx context.Context, opts ...ClientOption) (*grpc.ClientConn, error) {
return dial(ctx, false, opts...)
options, grpcOpts := makeOptions(false, opts...)
return dial(ctx, options, grpcOpts)
Copy link
Member

Choose a reason for hiding this comment

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

Dial has been deprecated. Can use NewClient directly? For example: return NewClient(opts...)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The NewClient function can be used directly;

However, the original timeout and block connection logic supported by the gRPC Dial will be completely discarded, rendering them incompatible.

For the sake of compatibility, it's advisable to follow the same pattern as the grpc-go library
Anti-Patterns of Client creation

For these reasons, using grpc.Dial is discouraged. Even though it is marked as deprecated, we will continue to support it until a v2 is released (and no plans for a v2 exist at the time this was written).

merely annotating the deprecated features. These can then be fully removed in a future major version update.

Ultimately, this decision hinges on the project maintainer's perspective. If deemed necessary, direct replacement without regard for the original logic's compatibility can be pursued. I will do this.

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
2 participants