ChannelPipeline
extension ChannelPipeline
-
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
, andRedisCommandHandler
.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 theRedisPubSubHandler
.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 theRedisCommandHandler
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 addRedisPubSubHandler() -> EventLoopFuture<RedisPubSubHandler>
Return Value
A
NIO.EventLoopFuture
that resolves the instance of the PubSubHandler that was added to the pipeline. -
Removes the provided Redis PubSub handler.
Declaration
Swift
public func removeRedisPubSubHandler(_ handler: RedisPubSubHandler) -> EventLoopFuture<Void>
Return Value
A
NIO.EventLoopFuture
that resolves when the handler was removed from the pipeline.