Class GrpcProxyBuilder<T>

  • Type Parameters:
    T - the type of the interface to be proxied
    All Implemented Interfaces:
    Builder<T>, Supplier<T>

    public class GrpcProxyBuilder<T>
    extends Object
    implements Builder<T>
    A builder for gRPC clients dynamic proxies.
    • Method Detail

      • create

        public static <T> GrpcProxyBuilder<T> create​(Class<T> type)
        Create a GrpcProxyBuilder that can build gRPC dynamic proxies for a given gRPC service interface using in-process channel.

        This method will attempt to create in-process channel for the default gRPC server. If you have changed the gRPC server name, use create(String, Class) instead.

        The class passed to this method should be properly annotated with Grpc and GrpcMethod annotations so that the proxy can properly route calls to the server.

        Type Parameters:
        T - the service type
        Parameters:
        type - the service type
        Returns:
        a GrpcProxyBuilder that can build dynamic proxies for the gRPC service
      • create

        public static <T> GrpcProxyBuilder<T> create​(String serverName,
                                                     Class<T> type)
        Create a GrpcProxyBuilder that can build gRPC dynamic proxies for a given gRPC service interface using in-process channel.

        The class passed to this method should be properly annotated with Grpc and GrpcMethod annotations so that the proxy can properly route calls to the server.

        Type Parameters:
        T - the service type
        Parameters:
        serverName - the name of the gRPC server proxy should connect to
        type - the service type
        Returns:
        a GrpcProxyBuilder that can build dynamic proxies for the gRPC service
      • create

        public static <T> GrpcProxyBuilder<T> create​(io.grpc.Channel channel,
                                                     Class<T> type)
        Create a GrpcProxyBuilder that can build gRPC dynamic proxies for a given gRPC service interface.

        The class passed to this method should be properly annotated with Grpc and GrpcMethod annotations so that the proxy can properly route calls to the server.

        Type Parameters:
        T - the service type
        Parameters:
        channel - the Channel to connect to the server
        type - the service type
        Returns:
        a GrpcProxyBuilder that can build dynamic proxies for the gRPC service
      • build

        public T build()
        Build a gRPC client dynamic proxy of the required type.
        Specified by:
        build in interface Builder<T>
        Returns:
        a gRPC client dynamic proxy