Class GrpcServiceClient
java.lang.Object
io.helidon.microprofile.grpc.client.GrpcServiceClient
A gRPC Client for a specific gRPC service.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder to build an instance ofGrpcServiceClient.static classA simpleStreamObserveradapter class that completes aCompletableFuturewhen 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.Builderbuilder(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 GrpcServiceClientcreate(io.grpc.Channel channel, ClientServiceDescriptor descriptor) Creates aGrpcServiceClient.<T> TCreate 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- theChannelto use to connect to the serverdescriptor- theClientServiceDescriptordescribing the gRPC service- Returns:
- a new instance of
GrpcServiceClient.Builder
-
create
Creates aGrpcServiceClient.- Parameters:
channel- theChannelto use to connect to the serverdescriptor- theClientServiceDescriptordescribing 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
CompletionStagethat 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- aStreamObserverto 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
Iteratorto 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- aStreamObserverto 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- anIterableof items to be streamed to the server- Returns:
- A
StreamObserverto 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- aStreamof items to be streamed to the server- Returns:
- A
StreamObserverto 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- aStreamObserverto receive the result- Returns:
- a
StreamObserverto 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- aStreamObserverto receive the result- Returns:
- A
StreamObserverto use to stream requests to the server
-