Package io.vertx.grpcio.client

## 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
  - a Protobuf message `API`: `GrpcClientRequest`/`GrpcClientResponse` with Protobuf messages to call any gRPC service in a generic way
  - a gRPC message `request(Address, MethodDescriptor)`: `GrpcClientRequest`/`GrpcClientRequest` with gRPC messages to call a given method of a gRPC service

- - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static GrpcClientBuilder<GrpcIoClient>` | `builder​(Vertx vertx)` | Provide a builder for `GrpcClient`, it can be used to configure advanced client settings like a load balancer or an address resolver.
    `default <Req,​Resp,​T> Future<T>` | `call​(MethodDescriptor<Req,​Resp> service, Handler<GrpcClientRequest<Req,​Resp>> requestHandler, java.util.function.Function<GrpcClientResponse<Req,​Resp>,​Future<T>> resultFn)` | Like `call(Address, MethodDescriptor, Handler, Function)` with the default remote server.
    `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`.
    `static GrpcIoClient` | `client​(Vertx vertx)` | Create a client.
    `static GrpcIoClient` | `client​(Vertx vertx, HttpClient client)` | Create a client wrapping an existing `HttpClient`.
    `static GrpcIoClient` | `client​(Vertx vertx, HttpClientOptions options)` | Create a client with the specified `options`.
    `static GrpcIoClient` | `client​(Vertx vertx, GrpcClientOptions options)` | Create a client.
    `static GrpcIoClient` | `client​(Vertx vertx, GrpcClientOptions grpcOptions, HttpClientOptions httpOptions)` | Create a client with the specified `options`.
    `<Req,​Resp> Future<GrpcClientRequest<Req,​Resp>>` | `request​(MethodDescriptor<Req,​Resp> service)` | Like `request(Address, MethodDescriptor)` with the default remote server.
    `<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.

    - ### Methods inherited from interface io.vertx.grpc.client.GrpcClient

      `close, request, request, request, request`

- - ### 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 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,
                                                          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

    - #### call

          default <Req,​Resp,​T> Future<T> call​(MethodDescriptor<Req,​Resp> service,
                                                          Handler<GrpcClientRequest<Req,​Resp>> requestHandler,
                                                          java.util.function.Function<GrpcClientResponse<Req,​Resp>,​Future<T>> resultFn)

      Like `call(Address, MethodDescriptor, Handler, Function)` with the default remote server.