From 98d53d16582bb3aa2b3079db1718c4d920e57c76 Mon Sep 17 00:00:00 2001 From: Luca Di Grazia Date: Sun, 4 Sep 2022 11:53:01 +0200 Subject: [PATCH] feat(redis): allow to configure redis connection pool Follows up https://github.com/quarkusio/quarkus/pull/9370#discussion_r443338006 and https://github.com/quarkusio/quarkus/issues/4453#issuecomment-674032630 --- .../client/runtime/RedisAPIProducer.java | 84 ++++++++++--------- .../redis/client/runtime/RedisConfig.java | 15 ---- 2 files changed, 45 insertions(+), 54 deletions(-) diff --git a/dataset/GitHub_Java/quarkusio.quarkus/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/client/runtime/RedisAPIProducer.java b/dataset/GitHub_Java/quarkusio.quarkus/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/client/runtime/RedisAPIProducer.java index c2b5f651569..3c3832b904f 100644 --- a/dataset/GitHub_Java/quarkusio.quarkus/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/client/runtime/RedisAPIProducer.java +++ b/dataset/GitHub_Java/quarkusio.quarkus/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/client/runtime/RedisAPIProducer.java @@ -6,6 +6,7 @@ import javax.annotation.PreDestroy; import javax.enterprise.context.ApplicationScoped; import javax.enterprise.inject.Produces; +import javax.inject.Singleton; import io.quarkus.redis.client.RedisClient; import io.quarkus.redis.client.reactive.ReactiveRedisClient; @@ -16,6 +17,7 @@ import io.vertx.redis.client.RedisClientType; import io.vertx.redis.client.RedisOptions; +@ApplicationScoped class RedisAPIProducer { private static final char AT = '@'; private static final char COLON = ':'; @@ -27,29 +29,17 @@ class RedisAPIProducer { private final RedisConfig config; - @Produces - @ApplicationScoped private final Redis vertxRedisClient; - @Produces - @ApplicationScoped private final RedisAPI redisAPI; - @Produces - @ApplicationScoped private final RedisClient redisClient; - @Produces - @ApplicationScoped private final ReactiveRedisClient reactiveClient; - @Produces - @ApplicationScoped - private final MutinyRedisClient mutinyRedisClient; + private final io.vertx.mutiny.redis.client.Redis mutinyRedisClient; - @Produces - @ApplicationScoped - private final MutinyRedisClientAPI mutinyRedisClientAPI; + private final io.vertx.mutiny.redis.client.RedisAPI mutinyRedisAPI; public RedisAPIProducer(RedisConfig config, Vertx vertx) { this.config = config; @@ -87,15 +77,51 @@ public RedisAPIProducer(RedisConfig config, Vertx vertx) { vertxRedisClient = Redis.createClient(vertx, options); redisAPI = RedisAPI.api(vertxRedisClient); - mutinyRedisClient = new MutinyRedisClient(vertxRedisClient); - mutinyRedisClientAPI = new MutinyRedisClientAPI(redisAPI); - redisClient = new RedisClientImpl(mutinyRedisClientAPI, timeout); - reactiveClient = new ReactiveRedisClientImpl(mutinyRedisClientAPI); + mutinyRedisClient = io.vertx.mutiny.redis.client.Redis.newInstance(vertxRedisClient); + mutinyRedisAPI = io.vertx.mutiny.redis.client.RedisAPI.api(mutinyRedisClient); + redisClient = new RedisClientImpl(mutinyRedisAPI, timeout); + reactiveClient = new ReactiveRedisClientImpl(mutinyRedisAPI); + } + + @Produces + @Singleton + Redis redis() { + return vertxRedisClient; + } + + @Produces + @Singleton + RedisAPI redisAPI() { + return redisAPI; + } + + @Produces + @Singleton + RedisClient redisClient() { + return redisClient; + } + + @Produces + @Singleton + ReactiveRedisClient reactiveRedisClient() { + return reactiveClient; + } + + @Produces + @Singleton + io.vertx.mutiny.redis.client.Redis mutinyRedisClient() { + return mutinyRedisClient; + } + + @Produces + @Singleton + io.vertx.mutiny.redis.client.RedisAPI mutinyRedisAPI() { + return mutinyRedisAPI; } @PreDestroy public void close() { - this.redisAPI.close(); + this.redis().close(); } private String buildConnectionString(InetSocketAddress address) { @@ -114,24 +140,4 @@ private String buildConnectionString(InetSocketAddress address) { return builder.toString(); } - - static class MutinyRedisClient extends io.vertx.mutiny.redis.client.Redis { - MutinyRedisClient(Redis delegate) { - super(delegate); - } - - MutinyRedisClient() { - super(null); - } - } - - static class MutinyRedisClientAPI extends io.vertx.mutiny.redis.client.RedisAPI { - MutinyRedisClientAPI(RedisAPI delegate) { - super(delegate); - } - - MutinyRedisClientAPI() { - super(null); - } - } } diff --git a/dataset/GitHub_Java/quarkusio.quarkus/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/client/runtime/RedisConfig.java b/dataset/GitHub_Java/quarkusio.quarkus/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/client/runtime/RedisConfig.java index 4d6658c8169..bba011bcd20 100644 --- a/dataset/GitHub_Java/quarkusio.quarkus/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/client/runtime/RedisConfig.java +++ b/dataset/GitHub_Java/quarkusio.quarkus/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/client/runtime/RedisConfig.java @@ -74,19 +74,4 @@ public class RedisConfig { */ @ConfigItem(defaultValue = "15") public Duration poolRecycleTimeout; - - /** - * Sets how much handlers is the client willing to queue. - *

- * The client will always work on pipeline mode, this means that messages can start queueing. - * Using this configuration option, you can control how much backlog you're willing to accept. - */ - @ConfigItem(defaultValue = "2048") - public int maxWaitingHandlers; - - /** - * Tune how much nested arrays are allowed on a redis response. This affects the parser performance. - */ - @ConfigItem(defaultValue = "32") - public int maxNestedArrays; }