Class ChannelBuilderOptions

java.lang.Object
org.springframework.grpc.client.ChannelBuilderOptions

public final class ChannelBuilderOptions extends Object
Options used by GrpcChannelFactory when building channels.

Provides functionality beyond what is available with the native channel builders (e.g. shutdownGracePeriod) and overrides some native channel builder behavior (e.g. interceptors.

Author:
Chris Bono
  • Method Details

    • interceptors

      public List<io.grpc.ClientInterceptor> interceptors()
      Gets the client interceptors to apply to the channel.
      Returns:
      the client interceptors to apply to the channel
    • mergeWithGlobalInterceptors

      public boolean mergeWithGlobalInterceptors()
      Gets whether the provided interceptors should be blended with the global interceptors.
      Returns:
      whether the provided interceptors should be blended with the global interceptors (default false)
    • shutdownGracePeriod

      public Duration shutdownGracePeriod()
      Gets the time to wait for the channel to gracefully shutdown.
      Returns:
      the time to wait for the channel to gracefully shutdown (default of 30s)
    • customizer

      public <T extends io.grpc.ManagedChannelBuilder<T>> GrpcChannelBuilderCustomizer<T> customizer()
      Gets the customizer to apply to the builder used to create the channel.
      Type Parameters:
      T - the type of the builder the customizer operates on
      Returns:
      the customizer to apply (default of GrpcChannelBuilderCustomizer.defaults())
    • defaults

      public static ChannelBuilderOptions defaults()
      Gets a new immutable options instance populated with default values.
      Returns:
      a new immutable options instance populated with default values.
    • withInterceptors

      public ChannelBuilderOptions withInterceptors(List<io.grpc.ClientInterceptor> interceptors)
      Set the client interceptors to apply to the channel.
      Parameters:
      interceptors - list of client interceptors to apply to the channel or empty list to clear out any previously set interceptors
      Returns:
      a new immutable options instance populated with the specified interceptors and the settings of this current options instance.
    • withInterceptorsMerge

      public ChannelBuilderOptions withInterceptorsMerge(boolean mergeWithGlobalInterceptors)
      Set whether the provided interceptors should be blended with the global interceptors.
      Parameters:
      mergeWithGlobalInterceptors - whether the provided interceptors should be
      Returns:
      a new immutable options instance populated with the specified merge setting and the settings of this current options instance.
    • withShutdownGracePeriod

      public ChannelBuilderOptions withShutdownGracePeriod(Duration shutdownGracePeriod)
      Set the time to wait for the channel to gracefully shutdown.
      Parameters:
      shutdownGracePeriod - the time to wait for the channel to gracefully shutdown
      Returns:
      a new immutable options instance populated with the specified shutdownGracePeriod and the settings of this current options instance.
    • withCustomizer

      public <T extends io.grpc.ManagedChannelBuilder<T>> ChannelBuilderOptions withCustomizer(GrpcChannelBuilderCustomizer<T> customizer)
      Set the customizer to apply to the builder used to create the channel.
      Type Parameters:
      T - type of builder the customizer operates on
      Parameters:
      customizer - the customizer to apply to the builder used to create the channel
      Returns:
      a new immutable options instance populated with the specified customizer and the settings of this current options instance.