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
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
GrpcClient.Stub<A extends ExchangeContext,
B extends GrpcClient.Stub<A, B>> A base gRPC client stub definition. -
Method Summary
Modifier and TypeMethodDescription<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>>
EbidirectionalStreaming
(B exchange, GrpcServiceName serviceName, String methodName, C defaultRequestInstance, D defaultResponseInstance) Converts an client HTTP exchange in a bidirectional streaming client gRPC exchange.<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>>
EclientStreaming
(B exchange, GrpcServiceName serviceName, String methodName, C defaultRequestInstance, D defaultResponseInstance) Converts an client HTTP exchange in a client streaming client gRPC exchange.<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>>
EserverStreaming
(B exchange, GrpcServiceName serviceName, String methodName, C defaultRequestInstance, D defaultResponseInstance) Converts an client HTTP exchange in a server streaming client gRPC exchange.<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>>
Eunary
(B exchange, GrpcServiceName serviceName, String methodName, C defaultRequestInstance, D defaultResponseInstance) Converts an client HTTP exchange in a unary client gRPC exchange.
-
Method Details
-
unary
<A extends ExchangeContext,B extends Exchange<A>, E unaryC extends com.google.protobuf.Message, D extends com.google.protobuf.Message, E extends GrpcExchange.Unary<A, C, D>> (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 typeB
- the client exchange typeC
- the request typeD
- the response typeE
- the gRPC unary exchange type- Parameters:
exchange
- the client exchangeserviceName
- the gRPC service namemethodName
- the gRPC service method namedefaultRequestInstance
- the default request instancedefaultResponseInstance
- the default response instance- Returns:
- a unary client gRPC exchange
-
clientStreaming
<A extends ExchangeContext,B extends Exchange<A>, E clientStreamingC extends com.google.protobuf.Message, D extends com.google.protobuf.Message, E extends GrpcExchange.ClientStreaming<A, C, D>> (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 typeB
- the client exchange typeC
- the request typeD
- the response typeE
- the gRPC unary exchange type- Parameters:
exchange
- the client exchangeserviceName
- the gRPC service namemethodName
- the gRPC service method namedefaultRequestInstance
- the default request instancedefaultResponseInstance
- the default response instance- Returns:
- a client streaming client gRPC exchange
-
serverStreaming
<A extends ExchangeContext,B extends Exchange<A>, E serverStreamingC extends com.google.protobuf.Message, D extends com.google.protobuf.Message, E extends GrpcExchange.ServerStreaming<A, C, D>> (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 typeB
- the client exchange typeC
- the request typeD
- the response typeE
- the gRPC unary exchange type- Parameters:
exchange
- the client exchangeserviceName
- the gRPC service namemethodName
- the gRPC service method namedefaultRequestInstance
- the default request instancedefaultResponseInstance
- the default response instance- Returns:
- a server streaming client gRPC exchange
-
bidirectionalStreaming
<A extends ExchangeContext,B extends Exchange<A>, E bidirectionalStreamingC extends com.google.protobuf.Message, D extends com.google.protobuf.Message, E extends GrpcExchange.BidirectionalStreaming<A, C, D>> (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 typeB
- the client exchange typeC
- the request typeD
- the response typeE
- the gRPC unary exchange type- Parameters:
exchange
- the client exchangeserviceName
- the gRPC service namemethodName
- the gRPC service method namedefaultRequestInstance
- the default request instancedefaultResponseInstance
- the default response instance- Returns:
- a bidirectional streaming client gRPC exchange
-