Channel

extension Channel
  • Adds the baseline channel handlers needed to support sending and receiving messages in Redis Serialization Protocol (RESP) format to the pipeline.

    For implementation details, see RedisMessageEncoder, RedisByteDecoder, and RedisCommandHandler.

    Pipeline chart

                                                RedisClient.send
                                                        |
                                                        v
    +-------------------------------------------------------------------+
    |                           ChannelPipeline         |               |
    |                                TAIL               |               |
    |    +---------------------------------------------------------+    |
    |    |                  RedisCommandHandler                    |    |
    |    +---------------------------------------------------------+    |
    |               ^                                   |               |
    |               |                                   v               |
    |    +---------------------+            +----------------------+    |
    |    |  RedisByteDecoder   |            |  RedisMessageEncoder |    |
    |    +---------------------+            +----------------------+    |
    |               |                                   |               |
    |               |              HEAD                 |               |
    +-------------------------------------------------------------------+
                    ^                                   |
                    |                                   v
            +-----------------+                +------------------+
            | [ Socket.read ] |                | [ Socket.write ] |
            +-----------------+                +------------------+
    

    Declaration

    Swift

    public func addBaseRedisHandlers() -> EventLoopFuture<Void>

    Return Value

    A NIO.EventLoopFuture that resolves after all handlers have been added to the pipeline.

  • Adds the channel handler that is responsible for handling everything related to Redis PubSub.

    Important

    The connection that manages this channel is responsible for removing the RedisPubSubHandler.

    Discussion

    PubSub responsibilities include managing subscription callbacks as well as parsing and dispatching messages received from Redis.

    For implementation details, see RedisPubSubHandler.

    The handler will be inserted in the NIO.ChannelPipeline just before the RedisCommandHandler instance.

    Pipeline chart

                                                RedisClient.send
                                                        |
                                                        v
    +-------------------------------------------------------------------+
    |                           ChannelPipeline         |               |
    |                                TAIL               |               |
    |    +---------------------------------------------------------+    |
    |    |                  RedisCommandHandler                    |    |
    |    +---------------------------------------------------------+    |
    |               ^                                   |               |
    |               |                                   v               |
    |    +---------------------------------------------------------+    |
    |    | (might forward)    RedisPubSubHandler     (forwards)    |----|<-----------+
    |    +---------------------------------------------------------+    |            |
    |               ^                                   |               |            +
    |               |                                   v               | RedisClient.subscribe/unsubscribe
    |    +---------------------+            +----------------------+    |
    |    |  RedisByteDecoder   |            |  RedisMessageEncoder |    |
    |    +---------------------+            +----------------------+    |
    |               |                                   |               |
    |               |              HEAD                 |               |
    +-------------------------------------------------------------------+
                    ^                                   |
                    |                                   v
            +-----------------+                +------------------+
            | [ Socket.read ] |                | [ Socket.write ] |
            +-----------------+                +------------------+
    

    Declaration

    Swift

    public func addPubSubHandler() -> EventLoopFuture<RedisPubSubHandler>

    Return Value

    A NIO.EventLoopFuture that resolves the instance of the PubSubHandler that was added to the pipeline.