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
Add a dedicated gRPC client builder. #3981
Labels
Comments
ikhoon
added a commit
to ikhoon/armeria
that referenced
this issue
Dec 23, 2021
Motivation: It would be useful to provide a dedicated gRPC client builder so that users can fluently/easily build their gRPC clients with various options. See line#3981 for details. Modifications: - Add `GrpcClients` and `GrpcClientBuilder` that provide various factory and builder methods to coveniently create gRPC client stub. - `gproto` will be used the default protocol if a `SerializationFormat` is not specified, - `GrpcClientOptions` is no longer needed to configure a gRPC client. - Add `UnwrappableChannel` to unwrap an intercepted `Channel`. - Migate code where the legacy gRPC client factory and builder is used. Result: You can now fluently build a gRPC client with various options using `GrpcClientBuilder`. ```java GrpcClients.builder(...) .decorator(myDecorators) .maxResponseMessageLength(MAX_MESSAGE_SIZE) .jsonMarshallerFactory(descriptor -> { ... }) .intercept(myInterceptors) .build(MyStub.class); ```
Merged
trustin
pushed a commit
that referenced
this issue
Jan 13, 2022
Motivation: It would be useful to provide a dedicated gRPC client builder so that users can fluently/easily build their gRPC clients with various options. See #3981 for details. Modifications: - Add `GrpcClients` and `GrpcClientBuilder` that provide various factory and builder methods to conveniently create gRPC client stub. - `gproto` will be used as the default protocol if a `SerializationFormat` is not specified, - `GrpcClientOptions` is no longer needed to configure a gRPC client. - Add `UnwrappableChannel` to unwrap an intercepted `Channel`. - Migrate code where the legacy gRPC client factory and builder is used. Result: - You can now fluently build a gRPC client with various options using `GrpcClientBuilder`. ```java GrpcClients.builder(...) .decorator(myDecorators) .maxResponseMessageLength(MAX_MESSAGE_SIZE) .jsonMarshallerFactory(descriptor -> { ... }) .intercept(myInterceptors) .build(MyStub.class); ``` - Closes #3981 Co-authored-by: minux <songmw725@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If users want to set gRPC specific options, they have to use
GrpcClientOptions
withClientBuilder
.For example:
However, the
GrpcClientOptions
style has two disadvantages.GrpcClientOptions
is not strongly related toClientBuilder
. So users should check Javadoc or reference documentation.This could be a learning curve for beginners.
It would be useful to provide a dedicated gRPC client builder so that users can fluently/easily build their gRPC clients with various options.
Implementation note:
We can reuse
ClientBuilder
andClients
to implementGrpcClients
andGrpcClientBuilder
.The text was updated successfully, but these errors were encountered: