Module lettuce.core

Class PubSubEndpoint<K,​V>

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
  • Constructor Details

    • 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 be null
      clientResources - client resources for this connection, must not be null.
  • Method Details

    • addListener

      public void addListener​(RedisPubSubListener<K,​V> listener)
      Add a new listener.
      Parameters:
      listener - the listener, must not be null.
    • removeListener

      public void removeListener​(RedisPubSubListener<K,​V> listener)
      Remove an existing listener.
      Parameters:
      listener - the listener, must not be null.
    • getListeners

      protected List<RedisPubSubListener<K,​V>> getListeners()
    • hasChannelSubscriptions

      public boolean hasChannelSubscriptions()
    • getChannels

      public Set<K> getChannels()
    • hasPatternSubscriptions

      public boolean hasPatternSubscriptions()
    • getPatterns

      public Set<K> getPatterns()
    • notifyChannelActive

      public void notifyChannelActive​(Channel channel)
      Description copied from interface: Endpoint
      Notify about channel activation.
      Specified by:
      notifyChannelActive in interface Endpoint
      Overrides:
      notifyChannelActive in class DefaultEndpoint
      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 interface RedisChannelWriter
      Overrides:
      write in class DefaultEndpoint
      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 interface RedisChannelWriter
      Overrides:
      write in class DefaultEndpoint
      Type Parameters:
      K1 - key type
      V1 - 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)
    • notifyListeners

      protected void notifyListeners​(PubSubMessage<K,​V> message)