java.lang.Object
io.helidon.grpc.client.GrpcServiceClient
A gRPC Client for a specific gRPC service.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Builder to build an instance ofGrpcServiceClient
.static class
A simpleStreamObserver
adapter class that completes aCompletableFuture
when the observer is completed. -
Method Summary
Modifier and TypeMethodDescription<ReqT,
RespT>
io.grpc.stub.StreamObserver<ReqT>bidiStreaming
(String methodName, io.grpc.stub.StreamObserver<RespT> observer) Invoke the specified bidirectional streaming method.<ReqT,
RespT>
Iterator<RespT>blockingServerStreaming
(String methodName, ReqT request) Invoke the specified server streaming method.<ReqT,
RespT>
RespTblockingUnary
(String methodName, ReqT request) Invoke the specified unary method with the specified request object.static GrpcServiceClient.Builder
builder
(io.grpc.Channel channel, ClientServiceDescriptor descriptor) Creates aGrpcServiceClient.Builder
.<ReqT,
RespT>
io.grpc.stub.StreamObserver<ReqT>clientStreaming
(String methodName, io.grpc.stub.StreamObserver<RespT> observer) Invoke the specified client streaming method.<ReqT,
RespT>
CompletionStage<RespT>clientStreaming
(String methodName, Iterable<ReqT> items) Invoke the specified client streaming method.<ReqT,
RespT>
CompletionStage<RespT>clientStreaming
(String methodName, Stream<ReqT> items) Invoke the specified client streaming method.static GrpcServiceClient
create
(io.grpc.Channel channel, ClientServiceDescriptor descriptor) Creates aGrpcServiceClient
.<T> T
Create a dynamic proxy for the specified interface that proxies calls to the wrapped gRPC service.<ReqT,
RespT>
voidserverStreaming
(String methodName, ReqT request, io.grpc.stub.StreamObserver<RespT> observer) Invoke the specified server streaming method.Obtain the service name.<ReqT,
RespT>
CompletionStage<RespT>Asynchronously invoke the specified unary method.<ReqT,
RespT>
voidInvoke the specified unary method.
-
Method Details
-
builder
public static GrpcServiceClient.Builder builder(io.grpc.Channel channel, ClientServiceDescriptor descriptor) Creates aGrpcServiceClient.Builder
.- Parameters:
channel
- theChannel
to use to connect to the serverdescriptor
- theClientServiceDescriptor
describing the gRPC service- Returns:
- a new instance of
GrpcServiceClient.Builder
-
create
Creates aGrpcServiceClient
.- Parameters:
channel
- theChannel
to use to connect to the serverdescriptor
- theClientServiceDescriptor
describing the gRPC service- Returns:
- a new instance of
GrpcServiceClient.Builder
-
serviceName
Obtain the service name.- Returns:
- The name of the service
-
proxy
Create a dynamic proxy for the specified interface that proxies calls to the wrapped gRPC service.- Type Parameters:
T
- the type of the returned proxy- Parameters:
type
- the interface to create a proxy forextraTypes
- extra types for the proxy to implement- Returns:
- a dynamic proxy that calls methods on this gRPC service
-
blockingUnary
Invoke the specified unary method with the specified request object.- Type Parameters:
ReqT
- the request typeRespT
- the response type- Parameters:
methodName
- the method name to be invokedrequest
- the request parameter- Returns:
- The result of this invocation
-
unary
Asynchronously invoke the specified unary method.- Type Parameters:
ReqT
- the request typeRespT
- the response type- Parameters:
methodName
- the method name to be invokedrequest
- the request parameter- Returns:
- A
CompletionStage
that will complete with the result of the unary method call
-
unary
public <ReqT,RespT> void unary(String methodName, ReqT request, io.grpc.stub.StreamObserver<RespT> observer) Invoke the specified unary method.- Type Parameters:
ReqT
- the request typeRespT
- the response type- Parameters:
methodName
- the method name to be invokedrequest
- the request parameterobserver
- aStreamObserver
to receive the result
-
blockingServerStreaming
Invoke the specified server streaming method.- Type Parameters:
ReqT
- the request typeRespT
- the response type- Parameters:
methodName
- the method name to be invokedrequest
- the request parameter- Returns:
- an
Iterator
to obtain the streamed results
-
serverStreaming
public <ReqT,RespT> void serverStreaming(String methodName, ReqT request, io.grpc.stub.StreamObserver<RespT> observer) Invoke the specified server streaming method.- Type Parameters:
ReqT
- the request typeRespT
- the response type- Parameters:
methodName
- the method name to be invokedrequest
- the request parameterobserver
- aStreamObserver
to receive the results
-
clientStreaming
public <ReqT,RespT> CompletionStage<RespT> clientStreaming(String methodName, Iterable<ReqT> items) Invoke the specified client streaming method.- Type Parameters:
ReqT
- the request typeRespT
- the response type- Parameters:
methodName
- the method name to be invokeditems
- anIterable
of items to be streamed to the server- Returns:
- A
StreamObserver
to retrieve the method call result
-
clientStreaming
Invoke the specified client streaming method.- Type Parameters:
ReqT
- the request typeRespT
- the response type- Parameters:
methodName
- the method name to be invokeditems
- aStream
of items to be streamed to the server- Returns:
- A
StreamObserver
to retrieve the method call result
-
clientStreaming
public <ReqT,RespT> io.grpc.stub.StreamObserver<ReqT> clientStreaming(String methodName, io.grpc.stub.StreamObserver<RespT> observer) Invoke the specified client streaming method.- Type Parameters:
ReqT
- the request typeRespT
- the response type- Parameters:
methodName
- the method name to be invokedobserver
- aStreamObserver
to receive the result- Returns:
- a
StreamObserver
to use to stream requests to the server
-
bidiStreaming
public <ReqT,RespT> io.grpc.stub.StreamObserver<ReqT> bidiStreaming(String methodName, io.grpc.stub.StreamObserver<RespT> observer) Invoke the specified bidirectional streaming method.- Type Parameters:
ReqT
- the request typeRespT
- the response type- Parameters:
methodName
- the method name to be invoked.observer
- aStreamObserver
to receive the result- Returns:
- A
StreamObserver
to use to stream requests to the server
-