From d3f54481aa1efdb0ad2e42785c7c455bf25db02a Mon Sep 17 00:00:00 2001 From: Tihomir Mateev Date: Sun, 1 Dec 2024 15:47:30 +0200 Subject: [PATCH] Restore API that was incidently deleted when introducing the JSON feature --- .../core/StatefulRedisConnectionImpl.java | 15 +++++++++++++ .../StatefulRedisClusterConnectionImpl.java | 16 ++++++++++++++ ...tefulRedisMasterReplicaConnectionImpl.java | 13 ++++++++++++ .../StatefulRedisPubSubConnectionImpl.java | 4 +++- .../StatefulRedisSentinelConnectionImpl.java | 21 +++++++++++++++++++ 5 files changed, 68 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/lettuce/core/StatefulRedisConnectionImpl.java b/src/main/java/io/lettuce/core/StatefulRedisConnectionImpl.java index a26c80a856..14ba7b5701 100644 --- a/src/main/java/io/lettuce/core/StatefulRedisConnectionImpl.java +++ b/src/main/java/io/lettuce/core/StatefulRedisConnectionImpl.java @@ -19,6 +19,7 @@ */ package io.lettuce.core; +import static io.lettuce.core.ClientOptions.DEFAULT_JSON_PARSER; import static io.lettuce.core.protocol.CommandType.*; import java.time.Duration; @@ -78,6 +79,20 @@ public class StatefulRedisConnectionImpl extends RedisChannelHandler * @param codec Codec used to encode/decode keys and values. * @param timeout Maximum time to wait for a response. */ + public StatefulRedisConnectionImpl(RedisChannelWriter writer, PushHandler pushHandler, RedisCodec codec, + Duration timeout) { + this(writer, pushHandler, codec, timeout, DEFAULT_JSON_PARSER); + } + + /** + * Initialize a new connection. + * + * @param writer the channel writer. + * @param pushHandler the handler for push notifications. + * @param codec Codec used to encode/decode keys and values. + * @param timeout Maximum time to wait for a response. + * @param parser the parser to use for JSON commands. + */ public StatefulRedisConnectionImpl(RedisChannelWriter writer, PushHandler pushHandler, RedisCodec codec, Duration timeout, Mono parser) { diff --git a/src/main/java/io/lettuce/core/cluster/StatefulRedisClusterConnectionImpl.java b/src/main/java/io/lettuce/core/cluster/StatefulRedisClusterConnectionImpl.java index 4a27ef1a14..c84193491b 100644 --- a/src/main/java/io/lettuce/core/cluster/StatefulRedisClusterConnectionImpl.java +++ b/src/main/java/io/lettuce/core/cluster/StatefulRedisClusterConnectionImpl.java @@ -19,6 +19,7 @@ */ package io.lettuce.core.cluster; +import static io.lettuce.core.ClientOptions.DEFAULT_JSON_PARSER; import static io.lettuce.core.protocol.CommandType.*; import java.lang.reflect.InvocationHandler; @@ -96,6 +97,21 @@ public class StatefulRedisClusterConnectionImpl extends RedisChannelHandle * @param codec Codec used to encode/decode keys and values. * @param timeout Maximum time to wait for a response. */ + public StatefulRedisClusterConnectionImpl(RedisChannelWriter writer, ClusterPushHandler pushHandler, RedisCodec codec, + Duration timeout) { + + this(writer, pushHandler, codec, timeout, DEFAULT_JSON_PARSER); + } + + /** + * Initialize a new connection. + * + * @param writer the channel writer + * @param pushHandler the Cluster push handler + * @param codec Codec used to encode/decode keys and values. + * @param timeout Maximum time to wait for a response. + * @param parser the JSON parser + */ public StatefulRedisClusterConnectionImpl(RedisChannelWriter writer, ClusterPushHandler pushHandler, RedisCodec codec, Duration timeout, Mono parser) { diff --git a/src/main/java/io/lettuce/core/masterreplica/StatefulRedisMasterReplicaConnectionImpl.java b/src/main/java/io/lettuce/core/masterreplica/StatefulRedisMasterReplicaConnectionImpl.java index 4908a6afef..ad1b5a53f6 100644 --- a/src/main/java/io/lettuce/core/masterreplica/StatefulRedisMasterReplicaConnectionImpl.java +++ b/src/main/java/io/lettuce/core/masterreplica/StatefulRedisMasterReplicaConnectionImpl.java @@ -8,12 +8,25 @@ import io.lettuce.core.json.JsonParser; import reactor.core.publisher.Mono; +import static io.lettuce.core.ClientOptions.DEFAULT_JSON_PARSER; + /** * @author Mark Paluch */ class StatefulRedisMasterReplicaConnectionImpl extends StatefulRedisConnectionImpl implements StatefulRedisMasterReplicaConnection { + /** + * Initialize a new connection. + * + * @param writer the channel writer + * @param codec Codec used to encode/decode keys and values. + * @param timeout Maximum time to wait for a response. + */ + StatefulRedisMasterReplicaConnectionImpl(MasterReplicaChannelWriter writer, RedisCodec codec, Duration timeout) { + super(writer, NoOpPushHandler.INSTANCE, codec, timeout, DEFAULT_JSON_PARSER); + } + /** * Initialize a new connection. * diff --git a/src/main/java/io/lettuce/core/pubsub/StatefulRedisPubSubConnectionImpl.java b/src/main/java/io/lettuce/core/pubsub/StatefulRedisPubSubConnectionImpl.java index 6e012f4328..91ef777f5a 100644 --- a/src/main/java/io/lettuce/core/pubsub/StatefulRedisPubSubConnectionImpl.java +++ b/src/main/java/io/lettuce/core/pubsub/StatefulRedisPubSubConnectionImpl.java @@ -36,6 +36,8 @@ import io.lettuce.core.pubsub.api.sync.RedisPubSubCommands; import io.netty.util.internal.logging.InternalLoggerFactory; +import static io.lettuce.core.ClientOptions.DEFAULT_JSON_PARSER; + /** * An thread-safe pub/sub connection to a Redis server. Multiple threads may share one {@link StatefulRedisPubSubConnectionImpl} * @@ -62,7 +64,7 @@ public class StatefulRedisPubSubConnectionImpl extends StatefulRedisConnec public StatefulRedisPubSubConnectionImpl(PubSubEndpoint endpoint, RedisChannelWriter writer, RedisCodec codec, Duration timeout) { - super(writer, endpoint, codec, timeout, null); + super(writer, endpoint, codec, timeout, DEFAULT_JSON_PARSER); this.endpoint = endpoint; endpoint.setConnectionState(getConnectionState()); } diff --git a/src/main/java/io/lettuce/core/sentinel/StatefulRedisSentinelConnectionImpl.java b/src/main/java/io/lettuce/core/sentinel/StatefulRedisSentinelConnectionImpl.java index a302847752..f5a9a9c625 100644 --- a/src/main/java/io/lettuce/core/sentinel/StatefulRedisSentinelConnectionImpl.java +++ b/src/main/java/io/lettuce/core/sentinel/StatefulRedisSentinelConnectionImpl.java @@ -36,6 +36,8 @@ import io.lettuce.core.sentinel.api.sync.RedisSentinelCommands; import reactor.core.publisher.Mono; +import static io.lettuce.core.ClientOptions.DEFAULT_JSON_PARSER; + /** * @author Mark Paluch */ @@ -52,6 +54,25 @@ public class StatefulRedisSentinelConnectionImpl extends RedisChannelHandl private final SentinelConnectionState connectionState = new SentinelConnectionState(); + /** + * Initialize a new Sentinel connection + * + * @param writer the writer used to write commands + * @param codec Codec used to encode/decode keys and values. + * @param timeout Maximum time to wait for a response. + */ + public StatefulRedisSentinelConnectionImpl(RedisChannelWriter writer, RedisCodec codec, Duration timeout) { + this(writer, codec, timeout, DEFAULT_JSON_PARSER); + } + + /** + * Initialize a new Sentinel connection + * + * @param writer the writer used to write commands + * @param codec Codec used to encode/decode keys and values. + * @param timeout Maximum time to wait for a response. + * @param parser the parser used to parse JSON responses + */ public StatefulRedisSentinelConnectionImpl(RedisChannelWriter writer, RedisCodec codec, Duration timeout, Mono parser) {