Interface GrpcClientProvider
-
Method Summary
Modifier and TypeMethodDescriptionforPlatformService(String platformService) Returns a provider for gRPC clients to services that belong to a platform service enabled in this project.<T extends akka.grpc.javadsl.AkkaGrpcClient>
TgrpcClientFor(Class<T> serviceClass, String serviceName) Returns a gRPC client to interact with the specified service.
-
Method Details
-
grpcClientFor
<T extends akka.grpc.javadsl.AkkaGrpcClient> T grpcClientFor(Class<T> serviceClass, String serviceName) Returns a gRPC client to interact with the specified service.If the serviceName is a service name without protocol or domain the client will be configured to connect to another service deployed with that name on the same Akka project. For a service that is part of a platform service, it connects to a service with that name in the same platform service. The runtime will take care of routing requests to the service and keeping the data safe by encrypting the connection between services and identifying the client as coming from this service.
If it is a full dns name prefixed with "http://" or "https://" it will connect to services available on the public internet.
The client lifecycle is managed by the runtime, service code should not call invalid input: '{@code close() on the client. // FIXME what about powerapi client interface for request headers? @param serviceClass A gRPC service client interface generated by Akka gRPC'
-
forPlatformService
Returns a provider for gRPC clients to services that belong to a platform service enabled in this project. A service name passed togrpcClientFor(Class, String)on the returned provider is resolved among the services of the platform service instead of the services of this project. The runtime routes and encrypts the calls the same way as calls to services in this project.The returned provider only accepts a bare service name, and throws
IllegalArgumentExceptionfor a host name or a URL.The platform service identifies the caller as a service of the project that the platform service is enabled in. Only
@Acl.Matcherrules with scopeAcl.Scope.PARENT_PROJECTin the platform service match such a caller. The platform service ignores the identity of the calling component.In dev mode and in the test kit, the service is looked up by name only, the same way as a service in this project. A mock registered in the test kit for a service name also applies to a service of that name in a platform service.
Calling a service in a platform service fails when the deployment has no project id, for example in a standalone deployment. A service that is part of a platform service can only call services in its own platform service. Passing the own platform service resolves names the same way as this provider.
- Parameters:
platformService- the name of the platform service, for examplemy-platform-service- Throws:
IllegalArgumentException- if the name is not a lowercase DNS label of at most 26 characters, if the name is the reserved namesvc, or if this service is part of another platform service
-