Package io.lettuce.core.pubsub
Class PubSubEndpoint<K,V>
- java.lang.Object
-
- io.lettuce.core.protocol.DefaultEndpoint
-
- io.lettuce.core.pubsub.PubSubEndpoint<K,V>
-
- All Implemented Interfaces:
AsyncCloseable
,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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addListener(RedisPubSubListener<K,V> listener)
Add a newlistener
.protected boolean
containsViolatingCommands(Collection<? extends RedisCommand<?,?,?>> redisCommands)
Set<K>
getChannels()
protected List<RedisPubSubListener<K,V>>
getListeners()
Set<K>
getPatterns()
boolean
hasChannelSubscriptions()
boolean
hasPatternSubscriptions()
boolean
isSubscribed()
void
notifyChannelActive(Channel channel)
Notify about channel activation.protected void
notifyListeners(PubSubMessage<K,V> message)
protected void
rejectCommand(RedisCommand<?,?,?> command)
protected void
rejectCommands(Collection<? extends RedisCommand<?,?,?>> redisCommands)
void
removeListener(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, getProtocolVersion, getPushListeners, initialState, isClosed, logPrefix, notifyChannelInactive, notifyDrainQueuedCommands, notifyException, registerConnectionWatchdog, removeListener, reset, setAutoFlushCommands, setConnectionFacade, writeToBuffer
-
-
-
-
Constructor Detail
-
PubSubEndpoint
public PubSubEndpoint(ClientOptions clientOptions, ClientResources clientResources)
Initialize a new instance that handles commands from the supplied queue.- Parameters:
clientOptions
- client options for this connection, must not benull
clientResources
- client resources for this connection, must not benull
.
-
-
Method Detail
-
addListener
public void addListener(RedisPubSubListener<K,V> listener)
Add a newlistener
.- Parameters:
listener
- the listener, must not benull
.
-
removeListener
public void removeListener(RedisPubSubListener<K,V> listener)
Remove an existinglistener
.- Parameters:
listener
- the listener, must not benull
.
-
getListeners
protected List<RedisPubSubListener<K,V>> getListeners()
-
hasChannelSubscriptions
public boolean hasChannelSubscriptions()
-
hasPatternSubscriptions
public boolean hasPatternSubscriptions()
-
notifyChannelActive
public void notifyChannelActive(Channel channel)
Description copied from interface:Endpoint
Notify about channel activation.- Specified by:
notifyChannelActive
in interfaceEndpoint
- Overrides:
notifyChannelActive
in classDefaultEndpoint
- Parameters:
channel
- the channel
-
write
public <K1,V1,T> RedisCommand<K1,V1,T> write(RedisCommand<K1,V1,T> command)
Description copied from interface:RedisChannelWriter
Write a command on the channel. The command may be changed/wrapped during write and the written instance is returned after the call.- Specified by:
write
in interfaceRedisChannelWriter
- Overrides:
write
in classDefaultEndpoint
T
- 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:RedisChannelWriter
Write multiple commands on the channel. The commands may be changed/wrapped during write and the written instance is returned after the call.- Specified by:
write
in interfaceRedisChannelWriter
- Overrides:
write
in classDefaultEndpoint
- Type Parameters:
K1
- key typeV1
- value type- Parameters:
redisCommands
- the Redis commands.- Returns:
- the written redis command
-
rejectCommand
protected void rejectCommand(RedisCommand<?,?,?> command)
-
rejectCommands
protected void rejectCommands(Collection<? extends RedisCommand<?,?,?>> redisCommands)
-
containsViolatingCommands
protected boolean containsViolatingCommands(Collection<? extends RedisCommand<?,?,?>> redisCommands)
-
isSubscribed
public boolean isSubscribed()
-
notifyListeners
protected void notifyListeners(PubSubMessage<K,V> message)
-
-