Class GrpcServiceClient


  • public class GrpcServiceClient
    extends Object
    A gRPC Client for a specific gRPC service.
    • Method Detail

      • serviceName

        public String serviceName()
        Obtain the service name.
        Returns:
        The name of the service
      • proxy

        public <T> T proxy​(Class<T> type,
                           Class<?>... extraTypes)
        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 for
        extraTypes - extra types for the proxy to implement
        Returns:
        a dynamic proxy that calls methods on this gRPC service
      • blockingUnary

        public <ReqT,​RespT> RespT blockingUnary​(String methodName,
                                                      ReqT request)
        Invoke the specified unary method with the specified request object.
        Type Parameters:
        ReqT - the request type
        RespT - the response type
        Parameters:
        methodName - the method name to be invoked
        request - the request parameter
        Returns:
        The result of this invocation
      • unary

        public <ReqT,​RespT> CompletionStage<RespT> unary​(String methodName,
                                                               ReqT request)
        Asynchronously invoke the specified unary method.
        Type Parameters:
        ReqT - the request type
        RespT - the response type
        Parameters:
        methodName - the method name to be invoked
        request - 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 type
        RespT - the response type
        Parameters:
        methodName - the method name to be invoked
        request - the request parameter
        observer - a StreamObserver to receive the result
      • blockingServerStreaming

        public <ReqT,​RespT> Iterator<RespT> blockingServerStreaming​(String methodName,
                                                                          ReqT request)
        Invoke the specified server streaming method.
        Type Parameters:
        ReqT - the request type
        RespT - the response type
        Parameters:
        methodName - the method name to be invoked
        request - 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 type
        RespT - the response type
        Parameters:
        methodName - the method name to be invoked
        request - the request parameter
        observer - a StreamObserver 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 type
        RespT - the response type
        Parameters:
        methodName - the method name to be invoked
        items - an Iterable of items to be streamed to the server
        Returns:
        A StreamObserver to retrieve the method call result
      • clientStreaming

        public <ReqT,​RespT> CompletionStage<RespT> clientStreaming​(String methodName,
                                                                         Stream<ReqT> items)
        Invoke the specified client streaming method.
        Type Parameters:
        ReqT - the request type
        RespT - the response type
        Parameters:
        methodName - the method name to be invoked
        items - a Stream 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 type
        RespT - the response type
        Parameters:
        methodName - the method name to be invoked
        observer - a StreamObserver 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 type
        RespT - the response type
        Parameters:
        methodName - the method name to be invoked.
        observer - a StreamObserver to receive the result
        Returns:
        A StreamObserver to use to stream requests to the server