diff --git a/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/client/runtime/RedisClientUtil.java b/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/client/runtime/RedisClientUtil.java index 4f58b86ee6a87..f1030014b42d2 100644 --- a/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/client/runtime/RedisClientUtil.java +++ b/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/client/runtime/RedisClientUtil.java @@ -78,35 +78,33 @@ public static RedisOptions buildOptions(RedisConfiguration redisConfig) { private static NetClientOptions toNetClientOptions(RedisConfiguration redisConfig) { NetClientOptions netClientOptions = new NetClientOptions() - .setTcpKeepAlive(true) - .setTcpNoDelay(true); + .setTcpKeepAlive(redisConfig.tcpKeepAlive) + .setTcpNoDelay(redisConfig.tcpNoDelay); - if (redisConfig.ssl.isPresent()) { - SslConfig sslConfig = redisConfig.ssl.get(); + SslConfig sslConfig = redisConfig.ssl; - netClientOptions - .setSsl(sslConfig.enabled) - .setTrustAll(sslConfig.trustAll); + netClientOptions + .setSsl(sslConfig.enabled) + .setTrustAll(sslConfig.trustAll); - configurePemTrustOptions(netClientOptions, sslConfig.trustCertificatePem); - configureJksTrustOptions(netClientOptions, sslConfig.trustCertificateJks); - configurePfxTrustOptions(netClientOptions, sslConfig.trustCertificatePfx); + configurePemTrustOptions(netClientOptions, sslConfig.trustCertificatePem); + configureJksTrustOptions(netClientOptions, sslConfig.trustCertificateJks); + configurePfxTrustOptions(netClientOptions, sslConfig.trustCertificatePfx); - configurePemKeyCertOptions(netClientOptions, sslConfig.keyCertificatePem); - configureJksKeyCertOptions(netClientOptions, sslConfig.keyCertificateJks); - configurePfxKeyCertOptions(netClientOptions, sslConfig.keyCertificatePfx); + configurePemKeyCertOptions(netClientOptions, sslConfig.keyCertificatePem); + configureJksKeyCertOptions(netClientOptions, sslConfig.keyCertificateJks); + configurePfxKeyCertOptions(netClientOptions, sslConfig.keyCertificatePfx); - netClientOptions.setReconnectAttempts(redisConfig.reconnectAttempts); - netClientOptions.setReconnectInterval(redisConfig.reconnectInterval.toMillis()); + netClientOptions.setReconnectAttempts(redisConfig.reconnectAttempts); + netClientOptions.setReconnectInterval(redisConfig.reconnectInterval.toMillis()); - if (redisConfig.idleTimeout.isPresent()) { - netClientOptions.setIdleTimeout(redisConfig.idleTimeout.get()); - } + if (redisConfig.idleTimeout.isPresent()) { + netClientOptions.setIdleTimeout(redisConfig.idleTimeout.get()); + } - if (sslConfig.hostnameVerificationAlgorithm.isPresent()) { - netClientOptions.setHostnameVerificationAlgorithm( - sslConfig.hostnameVerificationAlgorithm.get()); - } + if (sslConfig.hostnameVerificationAlgorithm.isPresent()) { + netClientOptions.setHostnameVerificationAlgorithm( + sslConfig.hostnameVerificationAlgorithm.get()); } return netClientOptions; diff --git a/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/client/runtime/RedisConfig.java b/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/client/runtime/RedisConfig.java index 474ae2eda2290..31ecc5bfc653f 100644 --- a/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/client/runtime/RedisConfig.java +++ b/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/client/runtime/RedisConfig.java @@ -8,6 +8,7 @@ import io.quarkus.redis.client.RedisClient; import io.quarkus.redis.client.RedisClientName; +import io.quarkus.runtime.annotations.ConfigDocSection; import io.quarkus.runtime.annotations.ConfigGroup; import io.quarkus.runtime.annotations.ConfigItem; import io.quarkus.runtime.annotations.ConfigPhase; @@ -168,7 +169,7 @@ public static class RedisConfiguration { /** * The interval between reconnection attempts when a pooled connection cannot be established on first try. */ - @ConfigItem(defaultValue = "PT1S") + @ConfigItem(defaultValue = "1") public Duration reconnectInterval; /** @@ -177,12 +178,24 @@ public static class RedisConfiguration { @ConfigItem(defaultValueDocumentation = "no timeout") public Optional idleTimeout; + /** + * Whether TCP keep alive is enabled + */ + @ConfigItem(defaultValue = "true") + public boolean tcpKeepAlive; + + /** + * Whether TCP no delay is enabled + */ + @ConfigItem(defaultValue = "true") + public boolean tcpNoDelay; + /** * SSL/TLS config. */ @ConfigItem @ConfigDocSection - public SslConfig> ssl; + public SslConfig ssl; } }