java.lang.Object
io.lettuce.core.resource.DefaultClientResources.Builder
- All Implemented Interfaces:
ClientResources.Builder
- Enclosing class:
- DefaultClientResources
public static class DefaultClientResources.Builder extends Object implements ClientResources.Builder
Builder for
DefaultClientResources.-
Method Summary
Modifier and Type Method Description DefaultClientResources.BuilderaddressResolverGroup(AddressResolverGroup<?> addressResolverGroup)Sets theAddressResolverGroupfor DNS resolution.DefaultClientResourcesbuild()DefaultClientResources.BuildercommandLatencyCollectorOptions(CommandLatencyCollectorOptions commandLatencyCollectorOptions)Deprecated.since 6.0.DefaultClientResources.BuildercommandLatencyPublisherOptions(EventPublisherOptions commandLatencyPublisherOptions)Sets theEventPublisherOptionsto publish command latency metrics using theEventBusif theCommandLatencyRecorderis an instance ofCommandLatencyCollectorthat allows latency metric retrieval.DefaultClientResources.BuildercommandLatencyRecorder(CommandLatencyRecorder commandLatencyRecorder)Sets theCommandLatencyRecorderthat can that can be used across different instances of the RedisClient.DefaultClientResources.BuildercomputationThreadPoolSize(int computationThreadPoolSize)Sets the thread pool size (number of threads to use) for computation operations (default value is the number of CPUs).DefaultClientResources.BuilderdnsResolver(DnsResolver dnsResolver)Sets theDnsResolverthat is used to resolve hostnames toInetAddress.DefaultClientResources.BuildereventBus(EventBus eventBus)Sets theEventBusthat can that can be used across different instances of the RedisClient.DefaultClientResources.BuildereventExecutorGroup(EventExecutorGroup eventExecutorGroup)Sets a sharedevent executor groupthat can be used across different instances ofRedisClientandRedisClusterClient.DefaultClientResources.BuildereventLoopGroupProvider(EventLoopGroupProvider eventLoopGroupProvider)Sets a sharedevent executor providerthat can be used across different instances ofRedisClientandRedisClusterClient.DefaultClientResources.BuilderioThreadPoolSize(int ioThreadPoolSize)Sets the thread pool size (number of threads to use) for I/O operations (default value is the number of CPUs).DefaultClientResources.BuildernettyCustomizer(NettyCustomizer nettyCustomizer)Sets theNettyCustomizerinstance to customize netty components during connection.DefaultClientResources.BuilderreconnectDelay(Delay reconnectDelay)Sets the stateless reconnectDelayto delay reconnect attempts.DefaultClientResources.BuilderreconnectDelay(Supplier<Delay> reconnectDelay)Sets the stateful reconnectSupplierto delay reconnect attempts.ClientResources.BuildersocketAddressResolver(SocketAddressResolver socketAddressResolver)ClientResources.BuilderthreadFactoryProvider(ThreadFactoryProvider threadFactoryProvider)DefaultClientResources.Buildertimer(Timer timer)Sets a sharedTimerthat can be used across different instances ofRedisClientandRedisClusterClientThe providedTimerinstance will not be shut down when shutting down the client resources.DefaultClientResources.Buildertracing(Tracing tracing)Sets theTracinginstance to trace Redis calls.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.lettuce.core.resource.ClientResources.Builder
commandLatencyCollector
-
Method Details
-
addressResolverGroup
public DefaultClientResources.Builder addressResolverGroup(AddressResolverGroup<?> addressResolverGroup)Sets theAddressResolverGroupfor DNS resolution. This option is only effective ifDnsResolvers.UNRESOLVEDis used asDnsResolver. Defaults toDefaultAddressResolverGroup.INSTANCEif netty-dns-resolver is not available, otherwise defaults toDnsAddressResolverGroup.- Specified by:
addressResolverGroupin interfaceClientResources.Builder- Parameters:
addressResolverGroup- theAddressResolverGroupinstance, must not benull.- Returns:
thisClientResources.Builder- Since:
- 6.1
-
commandLatencyPublisherOptions
public DefaultClientResources.Builder commandLatencyPublisherOptions(EventPublisherOptions commandLatencyPublisherOptions)Sets theEventPublisherOptionsto publish command latency metrics using theEventBusif theCommandLatencyRecorderis an instance ofCommandLatencyCollectorthat allows latency metric retrieval.- Specified by:
commandLatencyPublisherOptionsin interfaceClientResources.Builder- Parameters:
commandLatencyPublisherOptions- theEventPublisherOptionsto publish command latency metrics using theEventBus, must not benull.- Returns:
thisClientResources.Builder.
-
commandLatencyCollectorOptions
@Deprecated public DefaultClientResources.Builder commandLatencyCollectorOptions(CommandLatencyCollectorOptions commandLatencyCollectorOptions)Deprecated.since 6.0. ConfigureCommandLatencyRecorderdirectly usingCommandLatencyCollectorOptions.Sets theCommandLatencyCollectorOptionsthat can that can be used across different instances of the RedisClient. The options are only effective if nocommandLatencyCollectoris provided.- Specified by:
commandLatencyCollectorOptionsin interfaceClientResources.Builder- Parameters:
commandLatencyCollectorOptions- the command latency collector options, must not benull.- Returns:
thisDefaultClientResources.Builder.
-
commandLatencyRecorder
public DefaultClientResources.Builder commandLatencyRecorder(CommandLatencyRecorder commandLatencyRecorder)Sets theCommandLatencyRecorderthat can that can be used across different instances of the RedisClient.- Specified by:
commandLatencyRecorderin interfaceClientResources.Builder- Parameters:
commandLatencyRecorder- the command latency recorder, must not benull.- Returns:
thisDefaultClientResources.Builder.
-
computationThreadPoolSize
Sets the thread pool size (number of threads to use) for computation operations (default value is the number of CPUs). The thread pool size is only effective if noeventExecutorGroupis provided.- Specified by:
computationThreadPoolSizein interfaceClientResources.Builder- Parameters:
computationThreadPoolSize- the thread pool size, must be greater than0.- Returns:
thisDefaultClientResources.Builder.
-
dnsResolver
Sets theDnsResolverthat is used to resolve hostnames toInetAddress. Defaults toDnsResolvers.JVM_DEFAULT- Specified by:
dnsResolverin interfaceClientResources.Builder- Parameters:
dnsResolver- the DNS resolver, must not benull.- Returns:
thisDefaultClientResources.Builder.- Since:
- 4.3
-
eventBus
Sets theEventBusthat can that can be used across different instances of the RedisClient.- Specified by:
eventBusin interfaceClientResources.Builder- Parameters:
eventBus- the event bus, must not benull.- Returns:
thisDefaultClientResources.Builder.
-
eventLoopGroupProvider
public DefaultClientResources.Builder eventLoopGroupProvider(EventLoopGroupProvider eventLoopGroupProvider)Sets a sharedevent executor providerthat can be used across different instances ofRedisClientandRedisClusterClient. The providedEventLoopGroupProviderinstance will not be shut down when shutting down the client resources. You have to take care of that. This is an advanced configuration that should only be used if you know what you are doing.- Specified by:
eventLoopGroupProviderin interfaceClientResources.Builder- Parameters:
eventLoopGroupProvider- the shared eventLoopGroupProvider, must not benull.- Returns:
thisDefaultClientResources.Builder.
-
eventExecutorGroup
Sets a sharedevent executor groupthat can be used across different instances ofRedisClientandRedisClusterClient. The providedEventExecutorGroupinstance will not be shut down when shutting down the client resources. You have to take care of that. This is an advanced configuration that should only be used if you know what you are doing.- Specified by:
eventExecutorGroupin interfaceClientResources.Builder- Parameters:
eventExecutorGroup- the shared eventExecutorGroup, must not benull.- Returns:
thisDefaultClientResources.Builder.
-
nettyCustomizer
Sets theNettyCustomizerinstance to customize netty components during connection.- Specified by:
nettyCustomizerin interfaceClientResources.Builder- Parameters:
nettyCustomizer- the netty customizer instance, must not benull.- Returns:
- this
- Since:
- 4.4
-
ioThreadPoolSize
Sets the thread pool size (number of threads to use) for I/O operations (default value is the number of CPUs). The thread pool size is only effective if noeventLoopGroupProvideris provided.- Specified by:
ioThreadPoolSizein interfaceClientResources.Builder- Parameters:
ioThreadPoolSize- the thread pool size, must be greater0.- Returns:
thisDefaultClientResources.Builder.
-
reconnectDelay
Sets the stateless reconnectDelayto delay reconnect attempts. Defaults to binary exponential delay capped at 30 SECONDS.reconnectDelaymust be a statelessDelay.- Specified by:
reconnectDelayin interfaceClientResources.Builder- Parameters:
reconnectDelay- the reconnect delay, must not benull.- Returns:
- this
- Since:
- 4.3
-
reconnectDelay
Sets the stateful reconnectSupplierto delay reconnect attempts. Defaults to binary exponential delay capped at 30 SECONDS.- Specified by:
reconnectDelayin interfaceClientResources.Builder- Parameters:
reconnectDelay- the reconnect delay, must not benull.- Returns:
- this
- Since:
- 4.3
-
socketAddressResolver
Sets theSocketAddressResolverthat is used to resolveRedisURItoSocketAddress. Defaults toSocketAddressResolverusing the configuredDnsResolver.- Specified by:
socketAddressResolverin interfaceClientResources.Builder- Parameters:
socketAddressResolver- the socket address resolver, must not benull.- Returns:
thisClientResources.Builder.- Since:
- 5.1
-
threadFactoryProvider
Provide a defaultThreadFactoryProviderto obtainThreadFactoryfor apoolName.Applies only to threading resources created by
DefaultClientResourceswhen not configuringClientResources.timer(),ClientResources.eventExecutorGroup(), orClientResources.eventLoopGroupProvider().- Specified by:
threadFactoryProviderin interfaceClientResources.Builder- Parameters:
threadFactoryProvider- a provider to obtain aThreadFactoryfor apoolName, must not benull.- Returns:
thisClientResources.Builder.- Since:
- 6.1.1
- See Also:
eventExecutorGroup(EventExecutorGroup),eventLoopGroupProvider(EventLoopGroupProvider),timer(Timer)
-
timer
Sets a sharedTimerthat can be used across different instances ofRedisClientandRedisClusterClientThe providedTimerinstance will not be shut down when shutting down the client resources. You have to take care of that. This is an advanced configuration that should only be used if you know what you are doing.- Specified by:
timerin interfaceClientResources.Builder- Parameters:
timer- the sharedTimer, must not benull.- Returns:
thisDefaultClientResources.Builder.- Since:
- 4.3
-
tracing
Sets theTracinginstance to trace Redis calls.- Specified by:
tracingin interfaceClientResources.Builder- Parameters:
tracing- the tracer infrastructure instance, must not benull.- Returns:
- this
- Since:
- 5.1
-
build
- Specified by:
buildin interfaceClientResources.Builder- Returns:
- a new instance of
DefaultClientResources.
-