DATAREDIS-976 - Polishing.
ClusterConnectionProvider now accepts cluster-specific connection interfaces for Pub/Sub connections. Original pull request: #450 & #457
This commit is contained in:
committed by
Christoph Strobl
parent
ad54341953
commit
d14ca572d4
@@ -19,6 +19,7 @@ import io.lettuce.core.ReadFrom;
|
||||
import io.lettuce.core.api.StatefulConnection;
|
||||
import io.lettuce.core.cluster.RedisClusterClient;
|
||||
import io.lettuce.core.cluster.api.StatefulRedisClusterConnection;
|
||||
import io.lettuce.core.cluster.pubsub.StatefulRedisClusterPubSubConnection;
|
||||
import io.lettuce.core.codec.RedisCodec;
|
||||
import io.lettuce.core.pubsub.StatefulRedisPubSubConnection;
|
||||
|
||||
@@ -33,6 +34,7 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
* @author Mark Paluch
|
||||
* @author Christoph Strobl
|
||||
* @author Bruce Cloud
|
||||
* @since 2.0
|
||||
*/
|
||||
class ClusterConnectionProvider implements LettuceConnectionProvider, RedisClientProvider {
|
||||
@@ -93,7 +95,8 @@ class ClusterConnectionProvider implements LettuceConnectionProvider, RedisClien
|
||||
}
|
||||
}
|
||||
|
||||
if (connectionType.equals(StatefulRedisPubSubConnection.class)) {
|
||||
if (connectionType.equals(StatefulRedisPubSubConnection.class)
|
||||
|| connectionType.equals(StatefulRedisClusterPubSubConnection.class)) {
|
||||
|
||||
return client.connectPubSubAsync(codec) //
|
||||
.thenApply(connectionType::cast);
|
||||
|
||||
@@ -23,6 +23,7 @@ import io.lettuce.core.cluster.SlotHash;
|
||||
import io.lettuce.core.cluster.api.StatefulRedisClusterConnection;
|
||||
import io.lettuce.core.cluster.api.sync.RedisClusterCommands;
|
||||
import io.lettuce.core.cluster.models.partitions.Partitions;
|
||||
import io.lettuce.core.cluster.pubsub.StatefulRedisClusterPubSubConnection;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
@@ -1254,7 +1254,7 @@ public class LettuceConnection extends AbstractRedisConnection {
|
||||
|
||||
private final LettucePool pool;
|
||||
|
||||
/*
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.connection.lettuce.LettuceConnectionProvider#getConnection(java.lang.Class)
|
||||
*/
|
||||
@@ -1263,7 +1263,7 @@ public class LettuceConnection extends AbstractRedisConnection {
|
||||
return connectionType.cast(pool.getResource());
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.connection.lettuce.LettuceConnectionProvider#getConnectionAsync(java.lang.Class)
|
||||
*/
|
||||
@@ -1272,7 +1272,7 @@ public class LettuceConnection extends AbstractRedisConnection {
|
||||
throw new UnsupportedOperationException("Async operations not supported!");
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.connection.lettuce.LettuceConnectionProvider#release(io.lettuce.core.api.StatefulConnection)
|
||||
*/
|
||||
|
||||
@@ -35,7 +35,7 @@ class LettuceMessageListener implements RedisPubSubListener<byte[], byte[]> {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see io.lettuce.core.pubsub.RedisPubSubListener#message(java.lang.Object, java.lang.Object)
|
||||
*/
|
||||
@@ -43,7 +43,7 @@ class LettuceMessageListener implements RedisPubSubListener<byte[], byte[]> {
|
||||
listener.onMessage(new DefaultMessage(channel, message), null);
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see io.lettuce.core.pubsub.RedisPubSubListener#message(java.lang.Object, java.lang.Object, java.lang.Object)
|
||||
*/
|
||||
@@ -51,25 +51,25 @@ class LettuceMessageListener implements RedisPubSubListener<byte[], byte[]> {
|
||||
listener.onMessage(new DefaultMessage(channel, message), pattern);
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see io.lettuce.core.pubsub.RedisPubSubListener#subscribed(java.lang.Object, long)
|
||||
*/
|
||||
public void subscribed(byte[] channel, long count) {}
|
||||
|
||||
/*
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see io.lettuce.core.pubsub.RedisPubSubListener#psubscribed(java.lang.Object, long)
|
||||
*/
|
||||
public void psubscribed(byte[] pattern, long count) {}
|
||||
|
||||
/*
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see io.lettuce.core.pubsub.RedisPubSubListener#unsubscribed(java.lang.Object, long)
|
||||
*/
|
||||
public void unsubscribed(byte[] channel, long count) {}
|
||||
|
||||
/*
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see io.lettuce.core.pubsub.RedisPubSubListener#punsubscribed(java.lang.Object, long)
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user