swift-nio-redis/Sources/NIORedis/RESPPipelineSetup.swift

33 lines
1.0 KiB
Swift

//===----------------------------------------------------------------------===//
//
// This source file is part of the swift-nio-redis open source project
//
// Copyright (c) 2018-2019 ZeeZide GmbH. and the swift-nio-redis project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of SwiftNIO project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
import class NIO.ChannelPipeline
import class NIO.EventLoopFuture
public extension ChannelPipeline {
func configureRedisPipeline(first : Bool = false,
name : String = "de.zeezide.nio.RESP")
-> EventLoopFuture<Void>
{
#if swift(>=5)
return self.addHandler(RESPChannelHandler(), name: name,
position: first ? .first : .last)
#else
return self.add(name: name, handler: RESPChannelHandler(), first: first)
#endif
}
}