Skip to content

Commit

Permalink
Redis Client: add support for new configuration options
Browse files Browse the repository at this point in the history
The Vert.x Redis Client recently gained 2 new configuration options,
the preferred protocol version for protocol negotiation and a hash
slot cache TTL. This commit exposes these config options through
Quarkus configuration mechanism.

(cherry picked from commit dfe6985)
  • Loading branch information
Ladicek authored and gsmet committed Feb 6, 2024
1 parent 13f4243 commit 7b2e9fe
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,11 @@ public static Redis create(String name, Vertx vertx, RedisClientConfig config) {
options.setMaxWaitingHandlers(config.maxWaitingHandlers());

options.setProtocolNegotiation(config.protocolNegotiation());
config.preferredProtocolVersion().ifPresent(options::setPreferredProtocolVersion);
options.setPassword(config.password().orElse(null));
config.poolCleanerInterval().ifPresent(d -> options.setPoolCleanerInterval((int) d.toMillis()));
options.setPoolRecycleTimeout((int) config.poolRecycleTimeout().toMillis());
options.setHashSlotCacheTTL(config.hashSlotCacheTtl().toMillis());

config.role().ifPresent(options::setRole);
options.setType(config.clientType());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import io.quarkus.runtime.annotations.ConfigDocSection;
import io.quarkus.runtime.annotations.ConfigGroup;
import io.smallrye.config.WithDefault;
import io.vertx.redis.client.ProtocolVersion;
import io.vertx.redis.client.RedisClientType;
import io.vertx.redis.client.RedisReplicas;
import io.vertx.redis.client.RedisRole;
Expand Down Expand Up @@ -137,6 +138,24 @@ public interface RedisClientConfig {
@WithDefault("true")
boolean protocolNegotiation();

/**
* The preferred protocol version to be used during protocol negotiation. When not set,
* defaults to RESP 3. When protocol negotiation is disabled, this setting has no effect.
*/
@ConfigDocDefault("resp3")
Optional<ProtocolVersion> preferredProtocolVersion();

/**
* The TTL of the hash slot cache. A hash slot cache is used by the clustered Redis client
* to prevent constantly sending {@code CLUSTER SLOTS} commands to the first statically
* configured cluster node.
* <p>
* This setting is only meaningful in case of a clustered Redis client and has no effect
* otherwise.
*/
@WithDefault("1s")
Duration hashSlotCacheTtl();

/**
* TCP config.
*/
Expand Down Expand Up @@ -168,6 +187,8 @@ default String toDebugString() {
", reconnectAttempts=" + reconnectAttempts() +
", reconnectInterval=" + reconnectInterval() +
", protocolNegotiation=" + protocolNegotiation() +
", preferredProtocolVersion=" + preferredProtocolVersion() +
", hashSlotCacheTtl=" + hashSlotCacheTtl() +
", tcp=" + tcp() +
", tls=" + tls() +
'}';
Expand Down

0 comments on commit 7b2e9fe

Please sign in to comment.