Class ChannelBuilderOptions
java.lang.Object
org.springframework.grpc.client.ChannelBuilderOptions
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 Summary
Modifier and TypeMethodDescription<T extends io.grpc.ManagedChannelBuilder<T>>
GrpcChannelBuilderCustomizer<T> Gets the customizer to apply to the builder used to create the channel.static ChannelBuilderOptionsdefaults()Gets a new immutable options instance populated with default values.List<io.grpc.ClientInterceptor> Gets the client interceptors to apply to the channel.booleanGets whether the provided interceptors should be blended with the global interceptors.Gets the time to wait for the channel to gracefully shutdown.<T extends io.grpc.ManagedChannelBuilder<T>>
ChannelBuilderOptionswithCustomizer(GrpcChannelBuilderCustomizer<T> customizer) Set the customizer to apply to the builder used to create the channel.withInterceptors(List<io.grpc.ClientInterceptor> interceptors) Set the client interceptors to apply to the channel.withInterceptorsMerge(boolean mergeWithGlobalInterceptors) Set whether the provided interceptors should be blended with the global interceptors.withShutdownGracePeriod(Duration shutdownGracePeriod) Set the time to wait for the channel to gracefully shutdown.
-
Method Details
-
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
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
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
Gets a new immutable options instance populated with default values.- Returns:
- a new immutable options instance populated with default values.
-
withInterceptors
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
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
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
shutdownGracePeriodand 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
customizerand the settings of this current options instance.
-