Interface GrpcIoClient

All Superinterfaces:
GrpcClient

public interface GrpcIoClient extends GrpcClient
A gRPC client for Vert.x This server extends the GrpcClient to encode/decode messages in protobuf format using MethodDescriptor. This client exposes 2 levels of API
  • Method Details

    • builder

      static GrpcClientBuilder<GrpcIoClient> builder(Vertx vertx)
    • client

      static GrpcIoClient client(Vertx vertx)
      Create a client.
      Parameters:
      vertx - the vertx instance
      Returns:
      the created client
    • client

      static GrpcIoClient client(Vertx vertx, GrpcClientOptions options)
      Create a client.
      Parameters:
      vertx - the vertx instance
      Returns:
      the created client
    • client

      static GrpcIoClient client(Vertx vertx, GrpcClientOptions grpcOptions, HttpClientOptions httpOptions)
      Create a client with the specified options.
      Parameters:
      vertx - the vertx instance
      grpcOptions - the http client options
      httpOptions - the http client options
      Returns:
      the created client
    • client

      static GrpcIoClient client(Vertx vertx, HttpClientOptions options)
      Create a client with the specified options.
      Parameters:
      vertx - the vertx instance
      options - the http client options
      Returns:
      the created client
    • client

      static GrpcIoClient client(Vertx vertx, HttpClient client)
      Create a client wrapping an existing HttpClient.
      Parameters:
      vertx - the vertx instance
      client - the http client instance
      Returns:
      the created client
    • request

      <Req,Resp> Future<GrpcClientRequest<Req,Resp>> request(Address server, MethodDescriptor<Req,Resp> service)
      Connect to the remote server and create a request for given method of a hosted gRPC service.
      Parameters:
      server - the server hosting the service
      service - the service to be called
      Returns:
      a future request
    • request

      <Req,Resp> Future<GrpcClientRequest<Req,Resp>> request(MethodDescriptor<Req,Resp> service)
      Like request(Address, MethodDescriptor) with the default remote server.
    • call

      default <Req,Resp,T> Future<T> call(Address server, MethodDescriptor<Req,Resp> service, Handler<GrpcClientRequest<Req,Resp>> requestHandler, Function<GrpcClientResponse<Req,Resp>, Future<T>> resultFn)
      Call the 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()));
      Parameters:
      server - the server hosting the service
      service - the service to call
      requestHandler - the handler called to send the request
      resultFn - the function applied to extract the result.
      Returns:
      a future of the result
    • call

      default <Req,Resp,T> Future<T> call(MethodDescriptor<Req,Resp> service, Handler<GrpcClientRequest<Req,Resp>> requestHandler, Function<GrpcClientResponse<Req,Resp>, Future<T>> resultFn)
      Like call(Address, MethodDescriptor, Handler, Function) with the default remote server.