public class GrpcClient extends Object
#request(SocketAddress) API
: GrpcClientRequest
/GrpcClientResponse
with Protobuf messages to call any gRPC service in a generic wayrequest(io.vertx.rxjava.core.net.SocketAddress)
: GrpcClientRequest
/GrpcClientRequest
with gRPC messages to call a given method of a gRPC serviceoriginal
non RX-ified interface using Vert.x codegen.Modifier and Type | Field and Description |
---|---|
static io.vertx.lang.rx.TypeArg<GrpcClient> |
__TYPE_ARG |
Constructor and Description |
---|
GrpcClient(GrpcClient delegate) |
GrpcClient(Object delegate) |
Modifier and Type | Method and Description |
---|---|
<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 GrpcClient |
client(Vertx vertx)
Create a new client
|
static GrpcClient |
client(Vertx vertx,
HttpClientOptions options)
Create a new client
|
Future<Void> |
close()
Close this client.
|
boolean |
equals(Object o) |
GrpcClient |
getDelegate() |
int |
hashCode() |
static GrpcClient |
newInstance(GrpcClient arg) |
Future<GrpcClientRequest<Buffer,Buffer>> |
request(SocketAddress server)
Connect to the remote
server and create a request for any hosted gRPC service. |
<Req,Resp> Future<GrpcClientRequest<Req,Resp>> |
request(SocketAddress server,
io.grpc.MethodDescriptor<Req,Resp> service)
Connect to the remote
server and create a request for given method of a hosted gRPC service. |
<Req,Resp,T> |
rxCall(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 . |
Single<Void> |
rxClose()
Close this client.
|
Single<GrpcClientRequest<Buffer,Buffer>> |
rxRequest(SocketAddress server)
Connect to the remote
server and create a request for any hosted gRPC service. |
<Req,Resp> Single<GrpcClientRequest<Req,Resp>> |
rxRequest(SocketAddress server,
io.grpc.MethodDescriptor<Req,Resp> service)
Connect to the remote
server and create a request for given method of a hosted gRPC service. |
String |
toString() |
public static final io.vertx.lang.rx.TypeArg<GrpcClient> __TYPE_ARG
public GrpcClient(GrpcClient delegate)
public GrpcClient(Object delegate)
public GrpcClient getDelegate()
public static GrpcClient client(Vertx vertx)
vertx
- the vertx instancepublic static GrpcClient client(Vertx vertx, HttpClientOptions options)
vertx
- the vertx instanceoptions
- the client optionspublic Future<GrpcClientRequest<Buffer,Buffer>> request(SocketAddress server)
server
and create a request for any hosted gRPC service.server
- the server hosting the servicepublic Single<GrpcClientRequest<Buffer,Buffer>> rxRequest(SocketAddress server)
server
and create a request for any hosted gRPC service.server
- the server hosting the servicepublic <Req,Resp> Future<GrpcClientRequest<Req,Resp>> request(SocketAddress server, io.grpc.MethodDescriptor<Req,Resp> service)
server
and create a request for given method
of a hosted gRPC service.server
- the server hosting the serviceservice
- the service to be calledpublic <Req,Resp> Single<GrpcClientRequest<Req,Resp>> rxRequest(SocketAddress server, io.grpc.MethodDescriptor<Req,Resp> service)
server
and create a request for given method
of a hosted gRPC service.server
- the server hosting the serviceservice
- the service to be calledpublic <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 fut = client.call(..., req -> req.send(item), resp -> resp.last());
Future fut = client.call(..., req -> req.send(stream), resp -> resp.pipeTo(anotherService));
Future> fut = client.call(..., req -> req.send(stream), resp -> resp.collecting(Collectors.toList()));
server
- the server hosting the serviceservice
- the service to callrequestHandler
- the handler called to send the requestresultFn
- the function applied to extract the result.public <Req,Resp,T> Single<T> rxCall(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 fut = client.call(..., req -> req.send(item), resp -> resp.last());
Future fut = client.call(..., req -> req.send(stream), resp -> resp.pipeTo(anotherService));
Future> fut = client.call(..., req -> req.send(stream), resp -> resp.collecting(Collectors.toList()));
server
- the server hosting the serviceservice
- the service to callrequestHandler
- the handler called to send the requestresultFn
- the function applied to extract the result.public static GrpcClient newInstance(GrpcClient arg)
Copyright © 2023 Eclipse. All rights reserved.