What is the documentation for GrpcClientSettings?
This topic is based on a conversation between an anonymous user of Akka and our “Ask AI about Akka” bot in the documentation.
What is the documentation for GrpcClientSettings?
This topic is based on a conversation between an anonymous user of Akka and our “Ask AI about Akka” bot in the documentation.
GrpcClientSettings
is a configuration instance used for setting up a gRPC client in Akka. There are several ways to create a GrpcClientSettings
instance and an ActorSystem
is always required as it is used for default configuration and service discovery.
The simplest way to create a client is to provide a static host and port. For example, in Scala, you can use:
GrpcClientSettings.connectToServiceAt("localhost", 443)
And in Java:
GrpcClientSettings.connectToServiceAt("localhost", 443, actorSystem);
You can add further settings via the with methods. For example, in Scala:
GrpcClientSettings.connectToServiceAt("localhost", 443).withDeadline(1.second).withTls(false)
And in Java:
GrpcClientSettings.connectToServiceAt("localhost", 443, actorSystem)
.withDeadline(Duration.ofSeconds(1))
.withTls(false);
GrpcClientSettings
can also be used with Akka Discovery for endpoint discovery. For example, in Scala:
GrpcClientSettings
.usingServiceDiscovery(serviceName = "my-service")
.withServicePortName("https") // (optional) refine the lookup operation to only https ports
And in Java:
GrpcClientSettings
.usingServiceDiscovery("my-service", actorSystem)
.withServicePortName("https"); // (optional) refine the lookup operation to only https ports
For more details, you can refer to the Akka gRPC documentation.