Skip to content

Commit

Permalink
Public API methods removed by mistake when introducing RedisJSON #3070 (
Browse files Browse the repository at this point in the history
#3108) (#3109)

* Reverting some of the public constructors that were changed

* Restore public contracts
  • Loading branch information
tishun authored Dec 30, 2024
1 parent 53efbcf commit 97fc827
Show file tree
Hide file tree
Showing 7 changed files with 137 additions and 2 deletions.
12 changes: 12 additions & 0 deletions src/main/java/io/lettuce/core/AbstractRedisAsyncCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import java.util.Map;
import java.util.Set;

import static io.lettuce.core.ClientOptions.DEFAULT_JSON_PARSER;
import static io.lettuce.core.protocol.CommandType.EXEC;
import static io.lettuce.core.protocol.CommandType.GEORADIUSBYMEMBER_RO;
import static io.lettuce.core.protocol.CommandType.GEORADIUS_RO;
Expand Down Expand Up @@ -93,6 +94,7 @@ public abstract class AbstractRedisAsyncCommands<K, V> implements RedisAclAsyncC
*
* @param connection the connection to operate on
* @param codec the codec for command encoding
* @param parser the implementation of the {@link JsonParser} to use
*/
public AbstractRedisAsyncCommands(StatefulConnection<K, V> connection, RedisCodec<K, V> codec, Mono<JsonParser> parser) {
this.parser = parser;
Expand All @@ -101,6 +103,16 @@ public AbstractRedisAsyncCommands(StatefulConnection<K, V> connection, RedisCode
this.jsonCommandBuilder = new RedisJsonCommandBuilder<>(codec, parser);
}

/**
* Initialize a new instance.
*
* @param connection the connection to operate on
* @param codec the codec for command encoding
*/
public AbstractRedisAsyncCommands(StatefulConnection<K, V> connection, RedisCodec<K, V> codec) {
this(connection, codec, DEFAULT_JSON_PARSER);
}

@Override
public RedisFuture<Set<AclCategory>> aclCat() {
return dispatch(commandBuilder.aclCat());
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/io/lettuce/core/AbstractRedisReactiveCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
import java.util.Set;
import java.util.function.Supplier;

import static io.lettuce.core.ClientOptions.DEFAULT_JSON_PARSER;
import static io.lettuce.core.protocol.CommandType.EXEC;
import static io.lettuce.core.protocol.CommandType.GEORADIUSBYMEMBER_RO;
import static io.lettuce.core.protocol.CommandType.GEORADIUS_RO;
Expand Down Expand Up @@ -109,6 +110,7 @@ public abstract class AbstractRedisReactiveCommands<K, V>
*
* @param connection the connection to operate on.
* @param codec the codec for command encoding.
* @param parser the implementation of the {@link JsonParser} to use
*/
public AbstractRedisReactiveCommands(StatefulConnection<K, V> connection, RedisCodec<K, V> codec, Mono<JsonParser> parser) {
this.connection = connection;
Expand All @@ -119,6 +121,16 @@ public AbstractRedisReactiveCommands(StatefulConnection<K, V> connection, RedisC
this.tracingEnabled = clientResources.tracing().isEnabled();
}

/**
* Initialize a new instance.
*
* @param connection the connection to operate on.
* @param codec the codec for command encoding.
*/
public AbstractRedisReactiveCommands(StatefulConnection<K, V> connection, RedisCodec<K, V> codec) {
this(connection, codec, DEFAULT_JSON_PARSER);
}

private EventExecutorGroup getScheduler() {

EventExecutorGroup scheduler = this.scheduler;
Expand Down
12 changes: 11 additions & 1 deletion src/main/java/io/lettuce/core/RedisAsyncCommandsImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,22 @@ public class RedisAsyncCommandsImpl<K, V> extends AbstractRedisAsyncCommands<K,
*
* @param connection the connection to operate on
* @param codec the codec for command encoding
*
* @param parser the implementation of the {@link JsonParser} to use
*/
public RedisAsyncCommandsImpl(StatefulRedisConnection<K, V> connection, RedisCodec<K, V> codec, Mono<JsonParser> parser) {
super(connection, codec, parser);
}

/**
* Initialize a new instance.
*
* @param connection the connection to operate on
* @param codec the codec for command encoding
*/
public RedisAsyncCommandsImpl(StatefulRedisConnection<K, V> connection, RedisCodec<K, V> codec) {
super(connection, codec);
}

@Override
public StatefulRedisConnection<K, V> getStatefulConnection() {
return (StatefulRedisConnection<K, V>) super.getConnection();
Expand Down
12 changes: 11 additions & 1 deletion src/main/java/io/lettuce/core/RedisReactiveCommandsImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,23 @@ public class RedisReactiveCommandsImpl<K, V> extends AbstractRedisReactiveComman
*
* @param connection the connection to operate on.
* @param codec the codec for command encoding.
*
* @param parser the implementation of the {@link JsonParser} to use
*/
public RedisReactiveCommandsImpl(StatefulRedisConnection<K, V> connection, RedisCodec<K, V> codec,
Mono<JsonParser> parser) {
super(connection, codec, parser);
}

/**
* Initialize a new instance.
*
* @param connection the connection to operate on.
* @param codec the codec for command encoding.
*/
public RedisReactiveCommandsImpl(StatefulRedisConnection<K, V> connection, RedisCodec<K, V> codec) {
super(connection, codec);
}

@Override
public StatefulRedisConnection<K, V> getStatefulConnection() {
return (StatefulRedisConnection<K, V>) super.getConnection();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public class RedisAdvancedClusterAsyncCommandsImpl<K, V> extends AbstractRedisAs
*
* @param connection the stateful connection
* @param codec Codec used to encode/decode keys and values.
* @param parser the implementation of the {@link JsonParser} to use
* @deprecated since 5.1, use
* {@link #RedisAdvancedClusterAsyncCommandsImpl(StatefulRedisClusterConnection, RedisCodec, Mono)}.
*/
Expand All @@ -102,13 +103,39 @@ public RedisAdvancedClusterAsyncCommandsImpl(StatefulRedisClusterConnectionImpl<
*
* @param connection the stateful connection
* @param codec Codec used to encode/decode keys and values.
* @deprecated since 5.1, use
* {@link #RedisAdvancedClusterAsyncCommandsImpl(StatefulRedisClusterConnection, RedisCodec, Mono)}.
*/
@Deprecated
public RedisAdvancedClusterAsyncCommandsImpl(StatefulRedisClusterConnectionImpl<K, V> connection, RedisCodec<K, V> codec) {
super(connection, codec);
this.codec = codec;
}

/**
* Initialize a new connection.
*
* @param connection the stateful connection
* @param codec Codec used to encode/decode keys and values.
* @param parser the implementation of the {@link JsonParser} to use
*/
public RedisAdvancedClusterAsyncCommandsImpl(StatefulRedisClusterConnection<K, V> connection, RedisCodec<K, V> codec,
Mono<JsonParser> parser) {
super(connection, codec, parser);
this.codec = codec;
}

/**
* Initialize a new connection.
*
* @param connection the stateful connection
* @param codec Codec used to encode/decode keys and values.
*/
public RedisAdvancedClusterAsyncCommandsImpl(StatefulRedisClusterConnection<K, V> connection, RedisCodec<K, V> codec) {
super(connection, codec);
this.codec = codec;
}

@Override
public RedisFuture<String> clientSetname(K name) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public class RedisAdvancedClusterReactiveCommandsImpl<K, V> extends AbstractRedi
*
* @param connection the stateful connection.
* @param codec Codec used to encode/decode keys and values.
* @param parser the implementation of the {@link JsonParser} to use
* @deprecated since 5.2, use
* {@link #RedisAdvancedClusterReactiveCommandsImpl(StatefulRedisClusterConnection, RedisCodec, Mono)}.
*/
Expand All @@ -91,13 +92,40 @@ public RedisAdvancedClusterReactiveCommandsImpl(StatefulRedisClusterConnectionIm
*
* @param connection the stateful connection.
* @param codec Codec used to encode/decode keys and values.
* @deprecated since 5.2, use
* {@link #RedisAdvancedClusterReactiveCommandsImpl(StatefulRedisClusterConnection, RedisCodec, Mono)}.
*/
@Deprecated
public RedisAdvancedClusterReactiveCommandsImpl(StatefulRedisClusterConnectionImpl<K, V> connection,
RedisCodec<K, V> codec) {
super(connection, codec);
this.codec = codec;
}

/**
* Initialize a new connection.
*
* @param connection the stateful connection.
* @param codec Codec used to encode/decode keys and values.
* @param parser the implementation of the {@link JsonParser} to use
*/
public RedisAdvancedClusterReactiveCommandsImpl(StatefulRedisClusterConnection<K, V> connection, RedisCodec<K, V> codec,
Mono<JsonParser> parser) {
super(connection, codec, parser);
this.codec = codec;
}

/**
* Initialize a new connection.
*
* @param connection the stateful connection.
* @param codec Codec used to encode/decode keys and values.
*/
public RedisAdvancedClusterReactiveCommandsImpl(StatefulRedisClusterConnection<K, V> connection, RedisCodec<K, V> codec) {
super(connection, codec);
this.codec = codec;
}

@Override
public Mono<String> clientSetname(K name) {

Expand Down
36 changes: 36 additions & 0 deletions src/main/java/io/lettuce/core/cluster/RedisClusterClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,24 @@ protected <K, V> StatefulRedisConnectionImpl<K, V> newStatefulRedisConnection(Re
return new StatefulRedisConnectionImpl<>(channelWriter, pushHandler, codec, timeout, parser);
}

/**
* Create a new instance of {@link StatefulRedisConnectionImpl} or a subclass.
* <p>
* Subclasses of {@link RedisClusterClient} may override that method.
*
* @param channelWriter the channel writer
* @param pushHandler the handler for push notifications
* @param codec codec
* @param timeout default timeout
* @param <K> Key-Type
* @param <V> Value Type
* @return new instance of StatefulRedisConnectionImpl
*/
protected <K, V> StatefulRedisConnectionImpl<K, V> newStatefulRedisConnection(RedisChannelWriter channelWriter,
PushHandler pushHandler, RedisCodec<K, V> codec, Duration timeout) {
return new StatefulRedisConnectionImpl<>(channelWriter, pushHandler, codec, timeout);
}

/**
* Create a pub/sub connection to a redis socket address.
*
Expand Down Expand Up @@ -720,6 +738,24 @@ protected <V, K> StatefulRedisClusterConnectionImpl<K, V> newStatefulRedisCluste
return new StatefulRedisClusterConnectionImpl(channelWriter, pushHandler, codec, timeout, parser);
}

/**
* Create a new instance of {@link StatefulRedisClusterConnectionImpl} or a subclass.
* <p>
* Subclasses of {@link RedisClusterClient} may override that method.
*
* @param channelWriter the channel writer
* @param pushHandler the handler for push notifications
* @param codec codec
* @param timeout default timeout
* @param <K> Key-Type
* @param <V> Value Type
* @return new instance of StatefulRedisClusterConnectionImpl
*/
protected <V, K> StatefulRedisClusterConnectionImpl<K, V> newStatefulRedisClusterConnection(
RedisChannelWriter channelWriter, ClusterPushHandler pushHandler, RedisCodec<K, V> codec, Duration timeout) {
return new StatefulRedisClusterConnectionImpl(channelWriter, pushHandler, codec, timeout);
}

private <T, K, V> Mono<T> connect(Mono<SocketAddress> socketAddressSupplier, DefaultEndpoint endpoint,
StatefulRedisClusterConnectionImpl<K, V> connection, Supplier<CommandHandler> commandHandlerSupplier) {

Expand Down

0 comments on commit 97fc827

Please sign in to comment.