Class ServiceFactory


  • public class ServiceFactory
    extends Object
    Factory class that creates gRPC stubs of given class. It retrieves corresponding ManagedChannel object, adds authentication headers and required interceptors.
    • Method Detail

      • create

        public <SERVICE extends io.grpc.stub.AbstractStub<SERVICE>> SERVICE create​(Class<SERVICE> clazz,
                                                                                   Function<io.grpc.Channel,​SERVICE> service)
        Creates gRPC stub of given class with no timeout
        Type Parameters:
        SERVICE - indicates a gRPC stub class
        Parameters:
        clazz - gRPC stub class
        service - function that will be used to create gRPC stub
        Returns:
        gRPC stub of given class
      • create

        public <SERVICE extends io.grpc.stub.AbstractStub<SERVICE>> SERVICE create​(Class<SERVICE> clazz,
                                                                                   Function<io.grpc.Channel,​SERVICE> service,
                                                                                   Duration timeout)
        Creates gRPC stub of given class with given timeout
        Type Parameters:
        SERVICE - indicates a gRPC stub class
        Parameters:
        clazz - gRPC stub class
        service - function that will be used to create gRPC stub
        timeout - timeout for gRPC calls that will be enforced on created stub
        Returns:
        gRPC stub of given class
      • create

        public <SERVICE extends io.grpc.stub.AbstractStub<SERVICE>> SERVICE create​(io.grpc.ManagedChannel channel,
                                                                                   Function<io.grpc.Channel,​SERVICE> service)
        Creates gRPC stub of given class with no timeout
        Type Parameters:
        SERVICE - indicates a gRPC stub class
        Parameters:
        channel - ManagedChannel used to create a stub
        service - function that will be used to create gRPC stub
        Returns:
        gRPC stub of given class
      • create

        public <SERVICE extends io.grpc.stub.AbstractStub<SERVICE>> SERVICE create​(io.grpc.ManagedChannel channel,
                                                                                   Function<io.grpc.Channel,​SERVICE> service,
                                                                                   Duration timeout)
        Creates gRPC stub of given class with given timeout
        Type Parameters:
        SERVICE - indicates a gRPC stub class
        Parameters:
        channel - ManagedChannel used to create a stub
        service - function that will be used to create gRPC stub
        timeout - timeout for gRPC calls that will be enforced on created stub
        Returns:
        gRPC stub of given class