Interface GrpcClient


public interface GrpcClient

A gRPC client is used to transform client HTTP Exchange into unary, client streaming, server streaming or bidirectional streaming client GrpcExchange.

gRPC runs on top of HTTP/2 protocol, it defines four kinds of service method as defined by gRPC core concepts:

  • Unary RPCs: for request/response exchanges.
  • Client streaming RPCs: for stream/response exchanges.
  • Server streaming RPCs: for request/stream exchanges.
  • Bidirectional streaming RPCs: for stream/stream exchanges.

The GrpcClient defines four methods for converting a base HTTP/2 client Exchange into specific client GrpcExchange corresponding to above RPC methods.

The GrpcClient.Stub interface is an helper class used for generating gRPC client stub from Protocol buffer definitions.

Since:
1.9
Author:
Jeremy Kuhn
  • Method Details

    • unary

      <A extends ExchangeContext, B extends Exchange<A>, C extends com.google.protobuf.Message, D extends com.google.protobuf.Message, E extends GrpcExchange.Unary<A, C, D>> E unary(B exchange, GrpcServiceName serviceName, String methodName, C defaultRequestInstance, D defaultResponseInstance)

      Converts an client HTTP exchange in a unary client gRPC exchange.

      Type Parameters:
      A - the exchange context type
      B - the client exchange type
      C - the request type
      D - the response type
      E - the gRPC unary exchange type
      Parameters:
      exchange - the client exchange
      serviceName - the gRPC service name
      methodName - the gRPC service method name
      defaultRequestInstance - the default request instance
      defaultResponseInstance - the default response instance
      Returns:
      a unary client gRPC exchange
    • clientStreaming

      <A extends ExchangeContext, B extends Exchange<A>, C extends com.google.protobuf.Message, D extends com.google.protobuf.Message, E extends GrpcExchange.ClientStreaming<A, C, D>> E clientStreaming(B exchange, GrpcServiceName serviceName, String methodName, C defaultRequestInstance, D defaultResponseInstance)

      Converts an client HTTP exchange in a client streaming client gRPC exchange.

      Type Parameters:
      A - the exchange context type
      B - the client exchange type
      C - the request type
      D - the response type
      E - the gRPC unary exchange type
      Parameters:
      exchange - the client exchange
      serviceName - the gRPC service name
      methodName - the gRPC service method name
      defaultRequestInstance - the default request instance
      defaultResponseInstance - the default response instance
      Returns:
      a client streaming client gRPC exchange
    • serverStreaming

      <A extends ExchangeContext, B extends Exchange<A>, C extends com.google.protobuf.Message, D extends com.google.protobuf.Message, E extends GrpcExchange.ServerStreaming<A, C, D>> E serverStreaming(B exchange, GrpcServiceName serviceName, String methodName, C defaultRequestInstance, D defaultResponseInstance)

      Converts an client HTTP exchange in a server streaming client gRPC exchange.

      Type Parameters:
      A - the exchange context type
      B - the client exchange type
      C - the request type
      D - the response type
      E - the gRPC unary exchange type
      Parameters:
      exchange - the client exchange
      serviceName - the gRPC service name
      methodName - the gRPC service method name
      defaultRequestInstance - the default request instance
      defaultResponseInstance - the default response instance
      Returns:
      a server streaming client gRPC exchange
    • bidirectionalStreaming

      <A extends ExchangeContext, B extends Exchange<A>, C extends com.google.protobuf.Message, D extends com.google.protobuf.Message, E extends GrpcExchange.BidirectionalStreaming<A, C, D>> E bidirectionalStreaming(B exchange, GrpcServiceName serviceName, String methodName, C defaultRequestInstance, D defaultResponseInstance)

      Converts an client HTTP exchange in a bidirectional streaming client gRPC exchange.

      Type Parameters:
      A - the exchange context type
      B - the client exchange type
      C - the request type
      D - the response type
      E - the gRPC unary exchange type
      Parameters:
      exchange - the client exchange
      serviceName - the gRPC service name
      methodName - the gRPC service method name
      defaultRequestInstance - the default request instance
      defaultResponseInstance - the default response instance
      Returns:
      a bidirectional streaming client gRPC exchange