Interface GrpcIoClient

    • Method Detail

      • builder

        static GrpcClientBuilder<GrpcIoClient> builder​(Vertx vertx)
        Description copied from interface: GrpcClient
        Provide a builder for GrpcClient, it can be used to configure advanced client settings like a load balancer or an address resolver.

        Example usage: GrpcClient client = GrpcClient.builder(vertx).with(options)...build()

      • 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 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
      • call

        default <Req,​Resp,​T> Future<T> call​(Address server,
                                                        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.

        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