Package io.lettuce.core.resource
Interface ClientResources
-
- All Known Implementing Classes:
DefaultClientResources
public interface ClientResources
Strategy interface to provide all the infrastructure building blocks like environment settings and thread pools so that the client can work with it properly.ClientResources
can be shared amongst multiple client instances if created outside the client creation. Implementations ofClientResources
are stateful and must beshutdown()
after they are no longer in use.ClientResources
provides in particular:AddressResolverGroup
for DNS resolution.CommandLatencyRecorder
to collect latency details. Enabled usingDefaultCommandLatencyCollector
when HdrHistogram is on the classpath.EventBus
for client event dispatchingEventLoopGroupProvider
to obtain particularEventLoopGroups
EventExecutorGroup
to perform internal computation tasks- Reconnect
Delay
. SocketAddressResolver
for to map/resolve DNS addresses to aInetSocketAddress
.Timer
for schedulingTracing
to trace Redis commands.
- Since:
- 3.4
- Author:
- Mark Paluch, Mikhael Sokolov, Yohei Ueki
- See Also:
DefaultClientResources
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
ClientResources.Builder
Builder forClientResources
.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description AddressResolverGroup<?>
addressResolverGroup()
Return theAddressResolverGroup
instance for DNS resolution.static ClientResources.Builder
builder()
Create a newClientResources
using default settings.EventPublisherOptions
commandLatencyPublisherOptions()
Return theEventPublisherOptions
for latency event publishing.CommandLatencyRecorder
commandLatencyRecorder()
Return theCommandLatencyRecorder
.int
computationThreadPoolSize()
Return the pool size (number of threads) for all computation tasks.static ClientResources
create()
Create a newClientResources
using default settings.static ClientResources
create(ThreadFactoryProvider threadFactoryProvider)
Create a newClientResources
using default settings.DnsResolver
dnsResolver()
Return theDnsResolver
.EventBus
eventBus()
Return the event bus used to publish events.EventExecutorGroup
eventExecutorGroup()
Return the computation pool used for internal operations.EventLoopGroupProvider
eventLoopGroupProvider()
Return theEventLoopGroupProvider
that provides access to the particularevent loop groups
.int
ioThreadPoolSize()
Return the pool size (number of threads) for IO threads.ClientResources.Builder
mutate()
Return a builder to create newClientResources
whose settings are replicated from the currentClientResources
.NettyCustomizer
nettyCustomizer()
Return theNettyCustomizer
to customize netty components.Delay
reconnectDelay()
Return theDelay
for reconnect attempts.Future<Boolean>
shutdown()
Shutdown theClientResources
.Future<Boolean>
shutdown(long quietPeriod, long timeout, TimeUnit timeUnit)
Shutdown theClientResources
.SocketAddressResolver
socketAddressResolver()
Return theSocketAddressResolver
.Timer
timer()
Return theTimer
to schedule events.Tracing
tracing()
Return theTracing
instance to support tracing of Redis commands.
-
-
-
Method Detail
-
create
static ClientResources create()
Create a newClientResources
using default settings.- Returns:
- a new instance of default client resources.
-
create
static ClientResources create(ThreadFactoryProvider threadFactoryProvider)
Create a newClientResources
using default settings.- Parameters:
threadFactoryProvider
- provides aThreadFactory
to create threads.- Returns:
- a new instance of default client resources.
- Since:
- 6.1.1
-
builder
static ClientResources.Builder builder()
Create a newClientResources
using default settings.- Returns:
- a new instance of a default client resources.
-
mutate
ClientResources.Builder mutate()
Return a builder to create newClientResources
whose settings are replicated from the currentClientResources
.- Returns:
- a
ClientResources.Builder
to create newClientResources
whose settings are replicated from the currentClientResources
- Since:
- 5.1
-
shutdown
Future<Boolean> shutdown()
Shutdown theClientResources
.- Returns:
- eventually the success/failure of the shutdown without errors.
-
shutdown
Future<Boolean> shutdown(long quietPeriod, long timeout, TimeUnit timeUnit)
Shutdown theClientResources
.- Parameters:
quietPeriod
- the quiet period as described in the documentationtimeout
- the maximum amount of time to wait until the executor is shutdown regardless if a task was submitted during the quiet periodtimeUnit
- the unit ofquietPeriod
andtimeout
- Returns:
- eventually the success/failure of the shutdown without errors.
-
addressResolverGroup
AddressResolverGroup<?> addressResolverGroup()
Return theAddressResolverGroup
instance for DNS resolution.- Returns:
- the address resolver group.
- Since:
- 6.1
-
commandLatencyPublisherOptions
EventPublisherOptions commandLatencyPublisherOptions()
Return theEventPublisherOptions
for latency event publishing.- Returns:
- the
EventPublisherOptions
for latency event publishing.
-
commandLatencyRecorder
CommandLatencyRecorder commandLatencyRecorder()
Return theCommandLatencyRecorder
.- Returns:
- the command latency recorder.
- Since:
- 6.0
-
computationThreadPoolSize
int computationThreadPoolSize()
Return the pool size (number of threads) for all computation tasks.- Returns:
- the pool size (number of threads to use).
-
dnsResolver
DnsResolver dnsResolver()
Return theDnsResolver
.- Returns:
- the DNS resolver.
- Since:
- 4.3
-
eventBus
EventBus eventBus()
Return the event bus used to publish events.- Returns:
- the event bus
-
eventLoopGroupProvider
EventLoopGroupProvider eventLoopGroupProvider()
Return theEventLoopGroupProvider
that provides access to the particularevent loop groups
. lettuce requires at least two implementations:NioEventLoopGroup
for TCP/IP connections andEpollEventLoopGroup
for unix domain socket connections (epoll). You can useDefaultEventLoopGroupProvider
as default implementation or implement an ownEventLoopGroupProvider
to share existingEventLoopGroup's
with lettuce.- Returns:
- the
EventLoopGroupProvider
which provides access to the particularevent loop groups
-
eventExecutorGroup
EventExecutorGroup eventExecutorGroup()
Return the computation pool used for internal operations. Such tasks are periodic Redis Cluster and Redis Sentinel topology updates and scheduling of connection reconnection byConnectionWatchdog
.- Returns:
- the computation pool used for internal operations
-
ioThreadPoolSize
int ioThreadPoolSize()
Return the pool size (number of threads) for IO threads. The indicated size does not reflect the number for all IO threads. TCP and socket connections (epoll) require different IO pool.- Returns:
- the pool size (number of threads) for all IO tasks.
-
nettyCustomizer
NettyCustomizer nettyCustomizer()
Return theNettyCustomizer
to customize netty components.- Returns:
- the configured
NettyCustomizer
. - Since:
- 4.4
-
reconnectDelay
Delay reconnectDelay()
Return theDelay
for reconnect attempts. May return a different instance on each call.- Returns:
- the reconnect
Delay
. - Since:
- 4.3
-
socketAddressResolver
SocketAddressResolver socketAddressResolver()
Return theSocketAddressResolver
.- Returns:
- the socket address resolver.
- Since:
- 5.1
-
timer
Timer timer()
Return theTimer
to schedule events. A timer object may run single- or multi-threaded but must be used for scheduling of short-running jobs only. Long-running jobs should be scheduled and executed usingeventExecutorGroup()
.- Returns:
- the timer.
- Since:
- 4.3
-
-