In Lettuce, there are various timeout settings, primarily focusing on connection timeouts and command timeouts. When I attempted to configure Lettuce, I discovered that there are two distinct types of timeouts available, as shown below in the provided Kotlin code:
fun lettuceClientConfigurationBuilderCustomizer(): LettuceClientConfigurationBuilderCustomizer {
return LettuceClientConfigurationBuilderCustomizer { builder ->
val topologyRefreshOptions = ClusterTopologyRefreshOptions.builder()
.enablePeriodicRefresh(Duration.ofSeconds(30))
.dynamicRefreshSources(true)
.build()
val timeoutOptions = TimeoutOptions.builder()
.timeoutCommands()
.fixedTimeout(Duration.ofSeconds(2))
.build()
val socketOption = SocketOptions.builder()
.connectTimeout(Duration.ofSeconds(1))
.build()
val clientOptions = ClusterClientOptions.builder()
.topologyRefreshOptions(topologyRefreshOptions)
.timeoutOptions(timeoutOptions)
.socketOptions(socketOption)
.build()
builder.clientOptions(clientOptions)
builder.commandTimeout(Duration.ofSeconds(2))
}
}
In above, I think that timeout for socketOption
is connection timeout. But how about the timeout for TimeoutOptions
and builder.commandTimeout()
? both are saying that 'this is for command timeout' and I can't find out any differences. I guess builder.commandTimeout
is for global configuration and timeoutOptions
is for more granular configuration which means 'specifying timeout per commands'. Is this right ?