public interface GrpcIoClient extends GrpcClient
Extends the GrpcClient
so it can be utilized with MethodDescriptor
.
In Vert.x 5, the core GrpcClient
is decoupled from `io.grpc.*` packages to support JPMS.
Modifier and Type | Method and Description |
---|---|
default <Req,Resp,T> |
call(SocketAddress server,
io.grpc.MethodDescriptor<Req,Resp> service,
Handler<GrpcClientRequest<Req,Resp>> requestHandler,
java.util.function.Function<GrpcClientResponse<Req,Resp>,Future<T>> resultFn)
Call the
service gRPC service hosted by server . |
static GrpcIoClient |
client(Vertx vertx)
Create a new client
|
static GrpcIoClient |
client(Vertx vertx,
GrpcClientOptions options)
Create a new client
|
static GrpcIoClient |
client(Vertx vertx,
HttpClientOptions options)
Create a new client
|
close, request, request, request
static GrpcIoClient client(Vertx vertx)
client
in interface GrpcClient
vertx
- the vertx instancestatic GrpcIoClient client(Vertx vertx, GrpcClientOptions options)
client
in interface GrpcClient
vertx
- the vertx instancestatic GrpcIoClient client(Vertx vertx, HttpClientOptions options)
client
in interface GrpcClient
vertx
- the vertx instanceoptions
- the client optionsdefault <Req,Resp,T> Future<T> call(SocketAddress server, io.grpc.MethodDescriptor<Req,Resp> service, Handler<GrpcClientRequest<Req,Resp>> requestHandler, java.util.function.Function<GrpcClientResponse<Req,Resp>,Future<T>> resultFn)
service
gRPC service hosted by server
.
The requestHandler
is called to send the request, e.g. req -> req.send(item)
The responseFunction
extracts the result, e.g. resp -> resp.last()
It can be used in various ways:
Future<Resp> fut = client.call(..., req -> req.send(item), resp -> resp.last());
Future<Void> fut = client.call(..., req -> req.send(stream), resp -> resp.pipeTo(anotherService));
Future<List<Resp>> fut = client.call(..., req -> req.send(stream), resp -> resp.collecting(Collectors.toList()));
call
in interface GrpcClient
server
- the server hosting the serviceservice
- the service to callrequestHandler
- the handler called to send the requestresultFn
- the function applied to extract the result.Copyright © 2024 Eclipse. All rights reserved.