Class CompositeGrpcChannelFactory

java.lang.Object
org.springframework.grpc.client.CompositeGrpcChannelFactory
All Implemented Interfaces:
GrpcChannelFactory

public class CompositeGrpcChannelFactory extends Object implements GrpcChannelFactory
A composite GrpcChannelFactory that combines a list of channel factories.

The composite delegates channel creation to the first composed factory that supports the given target string.

Author:
Chris Bono
  • Constructor Details

    • CompositeGrpcChannelFactory

      public CompositeGrpcChannelFactory(List<GrpcChannelFactory> channelFactories)
      Creates a new CompositeGrpcChannelFactory with the given factories.
      Parameters:
      channelFactories - the channel factories
  • Method Details

    • supports

      public boolean supports(String target)
      Description copied from interface: GrpcChannelFactory
      Whether this factory supports the given target string.

      The target can be either a valid nameresolver-compliant URI or an authority string as described in Grpc.newChannelBuilder(String, ChannelCredentials), or the name of a user-configured channel (e.g. 'my-channel').

      Specified by:
      supports in interface GrpcChannelFactory
      Parameters:
      target - the target string
      Returns:
      whether this factory supports the given target string
    • supports

      public boolean supports(io.grpc.ClientInterceptor interceptor)
      Description copied from interface: GrpcChannelFactory
      Whether this factory supports the given global ClientInterceptor.
      Specified by:
      supports in interface GrpcChannelFactory
      Parameters:
      interceptor - the client interceptor to check support for
      Returns:
      whether this factory supports the given interceptor
    • createChannel

      public io.grpc.ManagedChannel createChannel(String target, ChannelBuilderOptions options)
      Description copied from interface: GrpcChannelFactory
      Creates a ManagedChannel for the given target string. The target can be

      The target can be either a valid nameresolver-compliant URI or an authority string as described in Grpc.newChannelBuilder(String, ChannelCredentials), or the name of a user-configured channel (e.g. 'my-channel').

      The returned channel is configured to use all globally registered interceptors and any user-provided interceptor if specified in the options.

      Specified by:
      createChannel in interface GrpcChannelFactory
      Parameters:
      target - the target string as described in method javadocs
      options - the options for building the created channel, or ChannelBuilderOptions.defaults() to use default options
      Returns:
      a channel for the given target