- gRPC Client Configuration
Configure the gRPC client using the Helidon configuration framework, either programmatically or via a configuration file.
As mentioned earlier, creating a
GrpcServiceClientinvolves:- Creating a
ClientServiceDescriptorwhich describes the methods in the service that this client can invoke. - Creating a gRPC
Channelthrough which the client communicates with the server.
- Creating a
Configuring the ClientServiceDescriptor
Configuring the ClientServiceDescriptor in your code
The only way to configure the ClientServiceDescriptor is in your application code.
ClientServiceDescriptor descriptor = ClientServiceDescriptor +
.builder(HelloService.class) // (1)
.unary("SayHello") // (2)
.build(); // (3)content_copy
- Create a builder for a
ClientServiceDescriptorfor theHelloService. - Specify that the
HelloServicehas a unary method namedSayHello. There are many other methods in this class that allow you to defineClientStreaming,ServerStreamingandBidirectionalmethods. - Build the
ClientServiceDescriptor.
Configuring the gRPC Channel
gRPC allows various channel configurations (deadlines, retries, interceptors etc.)
Please refer to gRPC documentation: https://grpc.io/grpc-java/javadoc/io/grpc/ManagedChannelBuilder.html.