Skip to content

Commit

Permalink
Restore API that was incidently deleted when introducing the JSON fea…
Browse files Browse the repository at this point in the history
…ture
  • Loading branch information
tishun committed Dec 1, 2024
1 parent d616b16 commit d3f5448
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 1 deletion.
15 changes: 15 additions & 0 deletions src/main/java/io/lettuce/core/StatefulRedisConnectionImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -78,6 +79,20 @@ public class StatefulRedisConnectionImpl<K, V> extends RedisChannelHandler<K, V>
* @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<K, V> 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<K, V> codec,
Duration timeout, Mono<JsonParser> parser) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -96,6 +97,21 @@ public class StatefulRedisClusterConnectionImpl<K, V> 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<K, V> 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<K, V> codec,
Duration timeout, Mono<JsonParser> parser) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<K, V> extends StatefulRedisConnectionImpl<K, V>
implements StatefulRedisMasterReplicaConnection<K, V> {

/**
* 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<K, V> codec, Duration timeout) {
super(writer, NoOpPushHandler.INSTANCE, codec, timeout, DEFAULT_JSON_PARSER);
}

/**
* Initialize a new connection.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}
*
Expand All @@ -62,7 +64,7 @@ public class StatefulRedisPubSubConnectionImpl<K, V> extends StatefulRedisConnec
public StatefulRedisPubSubConnectionImpl(PubSubEndpoint<K, V> endpoint, RedisChannelWriter writer, RedisCodec<K, V> codec,
Duration timeout) {

super(writer, endpoint, codec, timeout, null);
super(writer, endpoint, codec, timeout, DEFAULT_JSON_PARSER);
this.endpoint = endpoint;
endpoint.setConnectionState(getConnectionState());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -52,6 +54,25 @@ public class StatefulRedisSentinelConnectionImpl<K, V> 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<K, V> 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<K, V> codec, Duration timeout,
Mono<JsonParser> parser) {

Expand Down

0 comments on commit d3f5448

Please sign in to comment.