java.lang.Object
io.lettuce.core.protocol.DefaultEndpoint
io.lettuce.core.pubsub.PubSubEndpoint<K,V>
- All Implemented Interfaces:
AsyncCloseable,Endpoint,PushHandler,RedisChannelWriter,Closeable,AutoCloseable
- Direct Known Subclasses:
PubSubClusterEndpoint
public class PubSubEndpoint<K,V> extends DefaultEndpoint
- Author:
- Mark Paluch, dengliming
-
Field Summary
Fields inherited from class io.lettuce.core.protocol.DefaultEndpoint
channel -
Constructor Summary
Constructors Constructor Description PubSubEndpoint(ClientOptions clientOptions, ClientResources clientResources)Initialize a new instance that handles commands from the supplied queue. -
Method Summary
Modifier and Type Method Description voidaddListener(RedisPubSubListener<K,V> listener)Add a newlistener.protected booleancontainsViolatingCommands(Collection<? extends RedisCommand<?,?,?>> redisCommands)Set<K>getChannels()protected List<RedisPubSubListener<K,V>>getListeners()Set<K>getPatterns()booleanhasChannelSubscriptions()booleanhasPatternSubscriptions()voidnotifyChannelActive(Channel channel)Notify about channel activation.protected voidnotifyListeners(PubSubMessage<K,V> message)protected voidrejectCommand(RedisCommand<?,?,?> command)protected voidrejectCommands(Collection<? extends RedisCommand<?,?,?>> redisCommands)voidremoveListener(RedisPubSubListener<K,V> listener)Remove an existinglistener.<K1, V1, T> RedisCommand<K1,V1,T>write(RedisCommand<K1,V1,T> command)Write a command on the channel.<K1, V1> Collection<RedisCommand<K1,V1,?>>write(Collection<? extends RedisCommand<K1,V1,?>> redisCommands)Write multiple commands on the channel.Methods inherited from class io.lettuce.core.protocol.DefaultEndpoint
addListener, close, closeAsync, disconnect, doExclusive, drainCommands, flushCommands, getClientResources, getId, getPushListeners, initialState, isClosed, logPrefix, notifyChannelInactive, notifyDrainQueuedCommands, notifyException, registerConnectionWatchdog, removeListener, reset, setAutoFlushCommands, setConnectionFacade, writeToBuffer
-
Constructor Details
-
PubSubEndpoint
Initialize a new instance that handles commands from the supplied queue.- Parameters:
clientOptions- client options for this connection, must not benullclientResources- client resources for this connection, must not benull.
-
-
Method Details
-
addListener
Add a newlistener.- Parameters:
listener- the listener, must not benull.
-
removeListener
Remove an existinglistener.- Parameters:
listener- the listener, must not benull.
-
getListeners
-
hasChannelSubscriptions
public boolean hasChannelSubscriptions() -
getChannels
-
hasPatternSubscriptions
public boolean hasPatternSubscriptions() -
getPatterns
-
notifyChannelActive
Description copied from interface:EndpointNotify about channel activation.- Specified by:
notifyChannelActivein interfaceEndpoint- Overrides:
notifyChannelActivein classDefaultEndpoint- Parameters:
channel- the channel
-
write
Description copied from interface:RedisChannelWriterWrite a command on the channel. The command may be changed/wrapped during write and the written instance is returned after the call.- Specified by:
writein interfaceRedisChannelWriter- Overrides:
writein classDefaultEndpointT- result type- Parameters:
command- the Redis command.- Returns:
- the written Redis command.
-
write
public <K1, V1> Collection<RedisCommand<K1,V1,?>> write(Collection<? extends RedisCommand<K1,V1,?>> redisCommands)Description copied from interface:RedisChannelWriterWrite multiple commands on the channel. The commands may be changed/wrapped during write and the written instance is returned after the call.- Specified by:
writein interfaceRedisChannelWriter- Overrides:
writein classDefaultEndpoint- Type Parameters:
K1- key typeV1- value type- Parameters:
redisCommands- the Redis commands.- Returns:
- the written redis command
-
rejectCommand
-
rejectCommands
-
containsViolatingCommands
protected boolean containsViolatingCommands(Collection<? extends RedisCommand<?,?,?>> redisCommands) -
notifyListeners
-