Skip to content

Commit c1aff2a

Browse files
committed
Merge branch 'develop' into main
2 parents f8aba0d + a7406a7 commit c1aff2a

File tree

8 files changed

+48
-208
lines changed

8 files changed

+48
-208
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,5 @@ fastlane/test_output
6969
*.xcodeproj
7070
.build-linux
7171
Package.resolved
72+
.swiftpm
7273

.travis.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,18 @@ matrix:
77
include:
88
- os: Linux
99
dist: trusty
10-
env: SWIFT_SNAPSHOT_NAME="https://swift.org/builds/swift-4.2.3-release/ubuntu1404/swift-4.2.3-RELEASE/swift-4.2.3-RELEASE-ubuntu14.04.tar.gz"
10+
env: SWIFT_SNAPSHOT_NAME="https://swift.org/builds/swift-5.0.2-release/ubuntu1404/swift-5.0.2-RELEASE/swift-5.0.2-RELEASE-ubuntu14.04.tar.gz"
1111
sudo: required
1212
- os: Linux
1313
dist: trusty
14-
env: SWIFT_SNAPSHOT_NAME="https://swift.org/builds/swift-5.0-release/ubuntu1404/swift-5.0-RELEASE/swift-5.0-RELEASE-ubuntu14.04.tar.gz"
14+
env: SWIFT_SNAPSHOT_NAME="https://swift.org/builds/swift-5.1.3-release/ubuntu1404/swift-5.1.3-RELEASE/swift-5.1.3-RELEASE-ubuntu14.04.tar.gz"
15+
sudo: required
16+
- os: Linux
17+
dist: xenial
18+
env: SWIFT_SNAPSHOT_NAME="https://swift.org/builds/swift-5.2-release/ubuntu1604/swift-5.2-RELEASE/swift-5.2-RELEASE-ubuntu16.04.tar.gz"
1519
sudo: required
1620
- os: osx
17-
osx_image: xcode10.1
18-
- os: osx
19-
osx_image: xcode10.2
21+
osx_image: xcode11
2022

2123

2224
before_install:

Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:4.2
1+
// swift-tools-version:5.0
22

33
import PackageDescription
44

@@ -9,7 +9,7 @@ let package = Package(
99
],
1010
dependencies: [
1111
.package(url: "https://github.com/apple/swift-nio.git",
12-
from: "1.13.2"),
12+
from: "2.18.0")
1313
],
1414
targets: [
1515
.target(name: "NIORedis",

[email protected]

Lines changed: 0 additions & 19 deletions
This file was deleted.

Sources/NIORedis/RESPChannelHandler.swift

Lines changed: 32 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the swift-nio-redis open source project
44
//
5-
// Copyright (c) 2018-2019 ZeeZide GmbH. and the swift-nio-redis project authors
5+
// Copyright (c) 2018-2020 ZeeZide GmbH. and the swift-nio-redis project authors
66
// Licensed under Apache License v2.0
77
//
88
// See LICENSE.txt for license information
@@ -16,18 +16,18 @@ import NIO
1616

1717
open class RESPChannelHandler : ChannelDuplexHandler {
1818

19-
public typealias InboundErr = RESPParserError
19+
public typealias InboundErr = RESPParserError
2020

21-
public typealias InboundIn = ByteBuffer
22-
public typealias InboundOut = RESPValue
21+
public typealias InboundIn = ByteBuffer
22+
public typealias InboundOut = RESPValue
2323

24-
public typealias OutboundIn = RESPEncodable
25-
public typealias OutboundOut = ByteBuffer
24+
public typealias OutboundIn = RESPEncodable
25+
public typealias OutboundOut = ByteBuffer
2626

2727
private final let nilStringBuffer = ConstantBuffers.nilStringBuffer
2828
private final let nilArrayBuffer = ConstantBuffers.nilArrayBuffer
2929

30-
public final var parser = RESPParser()
30+
public final var parser = RESPParser()
3131

3232
public init() {}
3333

@@ -133,27 +133,15 @@ open class RESPChannelHandler : ChannelDuplexHandler {
133133
context.write(wrapOutboundOut(out), promise: promise)
134134
}
135135

136-
#if swift(>=5)
137-
@inline(__always)
138-
final func encode<S: Collection>(simpleString bytes: S,
139-
out: inout ByteBuffer)
140-
where S.Element == UInt8
141-
{
142-
out.writeInteger(UInt8(43)) // +
143-
out.writeBytes(bytes)
144-
out.writeBytes(eol)
145-
}
146-
#else
147-
@inline(__always)
148-
final func encode<S: ContiguousCollection>(simpleString bytes: S,
149-
out: inout ByteBuffer)
150-
where S.Element == UInt8
151-
{
152-
out.writeInteger(UInt8(43)) // +
153-
out.writeBytes(bytes)
154-
out.writeBytes(eol)
155-
}
156-
#endif
136+
@inline(__always)
137+
final func encode<S: Collection>(simpleString bytes: S,
138+
out: inout ByteBuffer)
139+
where S.Element == UInt8
140+
{
141+
out.writeInteger(UInt8(43)) // +
142+
out.writeBytes(bytes)
143+
out.writeBytes(eol)
144+
}
157145

158146
@inline(__always)
159147
final func encode(simpleString bytes: ByteBuffer, out: inout ByteBuffer) {
@@ -177,41 +165,22 @@ open class RESPChannelHandler : ChannelDuplexHandler {
177165
}
178166
}
179167

180-
#if swift(>=5)
181-
@inline(__always)
182-
final func encode<S: Collection>(bulkString bytes: S?,
183-
out: inout ByteBuffer)
184-
where S.Element == UInt8
185-
{
186-
if let s = bytes {
187-
out.writeInteger(UInt8(36)) // $
188-
out.write(integerAsString : Int(s.count))
189-
out.writeBytes(eol)
190-
out.writeBytes(s)
191-
out.writeBytes(eol)
192-
}
193-
else {
194-
out.writeBytes(nilString)
195-
}
168+
@inline(__always)
169+
final func encode<S: Collection>(bulkString bytes: S?,
170+
out: inout ByteBuffer)
171+
where S.Element == UInt8
172+
{
173+
if let s = bytes {
174+
out.writeInteger(UInt8(36)) // $
175+
out.write(integerAsString : Int(s.count))
176+
out.writeBytes(eol)
177+
out.writeBytes(s)
178+
out.writeBytes(eol)
196179
}
197-
#else
198-
@inline(__always)
199-
final func encode<S: ContiguousCollection>(bulkString bytes: S?,
200-
out: inout ByteBuffer)
201-
where S.Element == UInt8
202-
{
203-
if let s = bytes {
204-
out.writeInteger(UInt8(36)) // $
205-
out.write(integerAsString : Int(s.count))
206-
out.writeBytes(eol)
207-
out.writeBytes(s)
208-
out.writeBytes(eol)
209-
}
210-
else {
211-
out.writeBytes(nilString)
212-
}
180+
else {
181+
out.writeBytes(nilString)
213182
}
214-
#endif
183+
}
215184

216185
@inline(__always)
217186
final func encode(integer i: Int, out: inout ByteBuffer) {
@@ -270,36 +239,6 @@ open class RESPChannelHandler : ChannelDuplexHandler {
270239
}
271240
}
272241
}
273-
274-
275-
#if swift(>=5) // NIO 2 API - default
276-
#else // NIO 1 API Shims
277-
open func channelActive(ctx context: ChannelHandlerContext) {
278-
channelActive(context: context)
279-
}
280-
open func channelInactive(ctx context: ChannelHandlerContext) {
281-
channelInactive(context: context)
282-
}
283-
public func channelRead(ctx context: ChannelHandlerContext, data: NIOAny) {
284-
channelRead(context: context, data: data)
285-
}
286-
open func channelRead(ctx context: ChannelHandlerContext, value: RESPValue) {
287-
channelRead(context: context, value: value)
288-
}
289-
open func errorCaught(ctx context: ChannelHandlerContext, error: Error) {
290-
errorCaught(context: context, error: error)
291-
}
292-
public func write(ctx context: ChannelHandlerContext, data: NIOAny,
293-
promise: EventLoopPromise<Void>?)
294-
{
295-
write(context: context, data: data, promise: promise)
296-
}
297-
public final func write(ctx context: ChannelHandlerContext, value: RESPValue,
298-
promise: EventLoopPromise<Void>?)
299-
{
300-
write(context: context, value: value, promise: promise)
301-
}
302-
#endif // NIO 1 API Shims
303242
}
304243

305244
private let eol : ContiguousArray<UInt8> = [ 13, 10 ] // \r\n
@@ -310,49 +249,16 @@ fileprivate enum ConstantBuffers {
310249

311250
static let nilStringBuffer : ByteBuffer = {
312251
let alloc = ByteBufferAllocator()
313-
var bb = alloc.buffer(capacity: 6)
252+
var bb = alloc.buffer(capacity: 6)
314253
bb.writeBytes(nilString)
315254
return bb
316255
}()
317256

318257
static let nilArrayBuffer : ByteBuffer = {
319258
let alloc = ByteBufferAllocator()
320-
var bb = alloc.buffer(capacity: 6)
259+
var bb = alloc.buffer(capacity: 6)
321260
bb.writeBytes(nilArray)
322261
return bb
323262
}()
324263
}
325264

326-
#if swift(>=5)
327-
// NIO 2
328-
#else
329-
fileprivate extension ByteBuffer {
330-
// NIO 2 API for NIO 1
331-
332-
@inline(__always) @discardableResult
333-
mutating func writeString(_ string: String) -> Int {
334-
return self.write(string: string) ?? -1337 // never fails
335-
}
336-
337-
@inline(__always) @discardableResult
338-
mutating func writeInteger<T: FixedWidthInteger>(_ integer: T) -> Int {
339-
return self.write(integer: integer)
340-
}
341-
342-
@inline(__always) @discardableResult
343-
mutating func writeBuffer(_ buffer: inout ByteBuffer) -> Int {
344-
return self.write(buffer: &buffer)
345-
}
346-
347-
@inline(__always) @discardableResult
348-
mutating func writeBytes(_ bytes: UnsafeRawBufferPointer) -> Int {
349-
return self.write(bytes: bytes)
350-
}
351-
@inline(__always) @discardableResult
352-
mutating func writeBytes<Bytes: Sequence>(_ bytes: Bytes) -> Int
353-
where Bytes.Element == UInt8
354-
{
355-
return self.write(bytes: bytes)
356-
}
357-
}
358-
#endif // swift(<5)

Sources/NIORedis/RESPParser.swift

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the swift-nio-redis open source project
44
//
5-
// Copyright (c) 2018-2019 ZeeZide GmbH. and the swift-nio-redis project authors
5+
// Copyright (c) 2018-2020 ZeeZide GmbH. and the swift-nio-redis project authors
66
// Licensed under Apache License v2.0
77
//
88
// See LICENSE.txt for license information
@@ -18,7 +18,7 @@ import struct NIO.ByteBufferAllocator
1818
public enum RESPParserError : Error {
1919
case UnexpectedStartByte(char: UInt8, buffer: ByteBuffer)
2020
case UnexpectedEndByte (char: UInt8, buffer: ByteBuffer)
21-
case TransportError(Swift.Error)
21+
case TransportError (Swift.Error)
2222
case ProtocolError
2323
case UnexpectedNegativeCount
2424
case InternalInconsistency
@@ -333,27 +333,3 @@ public struct RESPParser {
333333
private var overflowBuffer : ByteBuffer?
334334

335335
}
336-
337-
#if swift(>=5)
338-
// NIO 2
339-
#else
340-
fileprivate extension ByteBuffer {
341-
// NIO 2 API for NIO 1
342-
343-
@inline(__always) @discardableResult
344-
mutating func writeInteger<T: FixedWidthInteger>(_ integer: T) -> Int {
345-
return self.write(integer: integer)
346-
}
347-
348-
@inline(__always) @discardableResult
349-
mutating func writeBytes(_ bytes: UnsafeRawBufferPointer) -> Int {
350-
return self.write(bytes: bytes)
351-
}
352-
@inline(__always) @discardableResult
353-
mutating func writeBytes<Bytes: Sequence>(_ bytes: Bytes) -> Int
354-
where Bytes.Element == UInt8
355-
{
356-
return self.write(bytes: bytes)
357-
}
358-
}
359-
#endif // swift(<5)

Sources/NIORedis/RESPPipelineSetup.swift

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the swift-nio-redis open source project
44
//
5-
// Copyright (c) 2018-2019 ZeeZide GmbH. and the swift-nio-redis project authors
5+
// Copyright (c) 2018-2020 ZeeZide GmbH. and the swift-nio-redis project authors
66
// Licensed under Apache License v2.0
77
//
88
// See LICENSE.txt for license information
@@ -21,12 +21,7 @@ public extension ChannelPipeline {
2121
name : String = "de.zeezide.nio.RESP")
2222
-> EventLoopFuture<Void>
2323
{
24-
#if swift(>=5)
25-
return self.addHandler(RESPChannelHandler(), name: name,
26-
position: first ? .first : .last)
27-
#else
28-
return self.add(name: name, handler: RESPChannelHandler(), first: first)
29-
#endif
24+
return self.addHandler(RESPChannelHandler(), name: name,
25+
position: first ? .first : .last)
3026
}
31-
3227
}

Sources/NIORedis/RESPValue.swift

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the swift-nio-redis open source project
44
//
5-
// Copyright (c) 2018-2019 ZeeZide GmbH. and the swift-nio-redis project authors
5+
// Copyright (c) 2018-2020 ZeeZide GmbH. and the swift-nio-redis project authors
66
// Licensed under Apache License v2.0
77
//
88
// See LICENSE.txt for license information
@@ -241,7 +241,6 @@ extension RESPValue : CustomStringConvertible {
241241
case .error(let e): return "<Error: \(e)>"
242242
}
243243
}
244-
245244
}
246245

247246

@@ -276,24 +275,4 @@ extension String {
276275
}
277276
}
278277
}
279-
280-
}
281-
282-
#if swift(>=5)
283-
// NIO 2
284-
#else
285-
fileprivate extension ByteBuffer {
286-
// NIO 2 API for NIO 1
287-
288-
@inline(__always) @discardableResult
289-
mutating func writeBytes(_ bytes: UnsafeRawBufferPointer) -> Int {
290-
return self.write(bytes: bytes)
291-
}
292-
@inline(__always) @discardableResult
293-
mutating func writeBytes<Bytes: Sequence>(_ bytes: Bytes) -> Int
294-
where Bytes.Element == UInt8
295-
{
296-
return self.write(bytes: bytes)
297-
}
298278
}
299-
#endif // swift(<5)

0 commit comments

Comments
 (0)