Interface GrpcChannelFactory

All Superinterfaces:
AutoCloseable
All Known Implementing Classes:
AbstractChannelFactory, InProcessChannelFactory, InProcessOrAlternativeChannelFactory, NettyChannelFactory, ShadedNettyChannelFactory

public interface GrpcChannelFactory extends AutoCloseable
This factory creates grpc Channels for a given service name. Implementations are encouraged to utilize connection pooling and thus close should be called before disposing it.
Since:
5/17/16
  • Method Details

    • createChannel

      default Channel createChannel(String name)
      Creates a new channel for the given service name. The returned channel will use all globally registered ClientInterceptors.

      Note: The underlying implementation might reuse existing ManagedChannels allow connection reuse.

      Parameters:
      name - The name of the service.
      Returns:
      The newly created channel for the given service.
    • createChannel

      default Channel createChannel(String name, List<ClientInterceptor> interceptors)
      Creates a new channel for the given service name. The returned channel will use all globally registered ClientInterceptors.

      Note: The underlying implementation might reuse existing ManagedChannels allow connection reuse.

      Note: The given interceptors will be appended to the global interceptors and applied using ClientInterceptors.interceptForward(Channel, ClientInterceptor...).

      Parameters:
      name - The name of the service.
      interceptors - A list of additional client interceptors that should be added to the channel.
      Returns:
      The newly created channel for the given service.
    • createChannel

      Channel createChannel(String name, List<ClientInterceptor> interceptors, boolean sortInterceptors)
      Creates a new channel for the given service name. The returned channel will use all globally registered ClientInterceptors.

      Note: The underlying implementation might reuse existing ManagedChannels allow connection reuse.

      Note: The given interceptors will be appended to the global interceptors and applied using ClientInterceptors.interceptForward(Channel, ClientInterceptor...).

      Parameters:
      name - The name of the service.
      interceptors - A list of additional client interceptors that should be added to the channel.
      sortInterceptors - Whether the interceptors (both global and custom) should be sorted before being applied.
      Returns:
      The newly created channel for the given service.
    • getConnectivityState

      default Map<String,ConnectivityState> getConnectivityState()
      Gets an unmodifiable map that contains the names of the created channel with their current ConnectivityState. This method will return an empty map, if the feature is not supported.
      Returns:
      A map with the channel names and their connectivity state.
    • close

      void close()
      Specified by:
      close in interface AutoCloseable