Skip to content

Commit 571d7bc

Browse files
committed
Housekeeping of code
- Move: `String.convertedToData()` to `NIORedisTests` as a test utility - Change: URLs in code comments to be Markdown links - Change: Code comments to be more correct
1 parent a17bfff commit 571d7bc

File tree

8 files changed

+28
-24
lines changed

8 files changed

+28
-24
lines changed

Sources/NIORedis/Commands/BasicCommands.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,23 @@ extension RedisConnection {
55
/// Select the Redis logical database having the specified zero-based numeric index.
66
/// New connections always use the database 0.
77
///
8-
/// https://redis.io/commands/select
8+
/// [https://redis.io/commands/select](https://redis.io/commands/select)
99
public func select(_ id: Int) -> EventLoopFuture<Void> {
1010
return command("SELECT", arguments: [RESPValue(bulk: id.description)])
1111
.map { _ in return () }
1212
}
1313

1414
/// Request for authentication in a password-protected Redis server.
1515
///
16-
/// https://redis.io/commands/auth
16+
/// [https://redis.io/commands/auth](https://redis.io/commands/auth)
1717
public func authorize(with password: String) -> EventLoopFuture<Void> {
1818
return command("AUTH", arguments: [RESPValue(bulk: password)])
1919
.map { _ in return () }
2020
}
2121

2222
/// Removes the specified keys. A key is ignored if it does not exist.
2323
///
24-
/// https://redis.io/commands/del
24+
/// [https://redis.io/commands/del](https://redis.io/commands/del)
2525
/// - Returns: A future number of keys that were removed.
2626
public func delete(_ keys: String...) -> EventLoopFuture<Int> {
2727
let keyArgs = keys.map { RESPValue(bulk: $0) }
@@ -37,7 +37,7 @@ extension RedisConnection {
3737
/// Set a timeout on key. After the timeout has expired, the key will automatically be deleted.
3838
/// A key with an associated timeout is often said to be volatile in Redis terminology.
3939
///
40-
/// https://redis.io/commands/expire
40+
/// [https://redis.io/commands/expire](https://redis.io/commands/expire)
4141
/// - Parameters:
4242
/// - after: The lifetime (in seconds) the key will expirate at.
4343
/// - Returns: A future bool indicating if the expiration was set or not.
@@ -55,7 +55,7 @@ extension RedisConnection {
5555
/// If the key does not exist the value will be `nil`.
5656
/// An error is resolved if the value stored at key is not a string, because GET only handles string values.
5757
///
58-
/// https://redis.io/commands/get
58+
/// [https://redis.io/commands/get](https://redis.io/commands/get)
5959
public func get(_ key: String) -> EventLoopFuture<String?> {
6060
return command("GET", arguments: [RESPValue(bulk: key)])
6161
.map { return $0.string }
@@ -65,7 +65,7 @@ extension RedisConnection {
6565
/// If key already holds a value, it is overwritten, regardless of its type.
6666
/// Any previous time to live associated with the key is discarded on successful SET operation.
6767
///
68-
/// https://redis.io/commands/set
68+
/// [https://redis.io/commands/set](https://redis.io/commands/set)
6969
public func set(_ key: String, to value: String) -> EventLoopFuture<Void> {
7070
return command("SET", arguments: [RESPValue(bulk: key), RESPValue(bulk: value)])
7171
.map { _ in return () }

Sources/NIORedis/RESP/RESPDecoder.swift

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ private extension ByteBuffer {
2828

2929
/// Handles incoming byte messages from Redis and decodes them according to the RESP protocol.
3030
///
31-
/// See: https://redis.io/topics/protocol
31+
/// See: [https://redis.io/topics/protocol](https://redis.io/topics/protocol)
3232
public final class RESPDecoder {
3333
/// Representation of a `RESPDecoder.parse(at:from:) result, with either a decoded `RESPValue` or an indicator
3434
/// that the buffer contains an incomplete RESP message from the position provided.
@@ -41,7 +41,7 @@ public final class RESPDecoder {
4141

4242
/// Attempts to parse the `ByteBuffer`, starting at the specified position, following the RESP specification.
4343
///
44-
/// See https://redis.io/topics/protocol
44+
/// See [https://redis.io/topics/protocol](https://redis.io/topics/protocol)
4545
/// - Parameters:
4646
/// - at: The index of the buffer that should be considered the "front" to begin message parsing.
4747
/// - from: The buffer that contains the bytes that need to be decoded.
@@ -76,8 +76,12 @@ public final class RESPDecoder {
7676
)
7777
}
7878
}
79+
}
80+
81+
// Parsing
7982

80-
/// See https://redis.io/topics/protocol#resp-simple-strings
83+
extension RESPDecoder {
84+
/// See [https://redis.io/topics/protocol#resp-simple-strings](https://redis.io/topics/protocol#resp-simple-strings)
8185
func _parseSimpleString(at position: inout Int, from buffer: inout ByteBuffer) throws -> String? {
8286
let byteCount = buffer.readableBytes - position
8387
guard
@@ -108,7 +112,7 @@ public final class RESPDecoder {
108112
return String(bytes: bytes[ ..<(expectedNewlinePosition - 1) ], encoding: .utf8)
109113
}
110114

111-
/// See https://redis.io/topics/protocol#resp-integers
115+
/// See [https://redis.io/topics/protocol#resp-integers](https://redis.io/topics/protocol#resp-integers)
112116
func _parseInteger(at position: inout Int, from buffer: inout ByteBuffer) throws -> Int? {
113117
guard let string = try _parseSimpleString(at: &position, from: &buffer) else { return nil }
114118

@@ -122,7 +126,7 @@ public final class RESPDecoder {
122126
return number
123127
}
124128

125-
/// See https://redis.io/topics/protocol#resp-bulk-strings
129+
/// See [https://redis.io/topics/protocol#resp-bulk-strings](https://redis.io/topics/protocol#resp-bulk-strings)
126130
func _parseBulkString(at position: inout Int, from buffer: inout ByteBuffer) throws -> ParsingState {
127131
guard let size = try _parseInteger(at: &position, from: &buffer) else { return .notYetParsed }
128132

@@ -155,7 +159,7 @@ public final class RESPDecoder {
155159
)
156160
}
157161

158-
/// See https://redis.io/topics/protocol#resp-arrays
162+
/// See [https://redis.io/topics/protocol#resp-arrays](https://redis.io/topics/protocol#resp-arrays)
159163
func _parseArray(at position: inout Int, from buffer: inout ByteBuffer) throws -> ParsingState {
160164
guard let arraySize = try _parseInteger(at: &position, from: &buffer) else { return .notYetParsed }
161165
guard arraySize > -1 else { return .parsed(.null) }

Sources/NIORedis/RESP/RESPEncoder.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ public final class RESPEncoder {
66

77
/// Encodes the `RedisValue` to bytes, following the RESP specification.
88
///
9-
/// See https://redis.io/topics/protocol
9+
/// See [https://redis.io/topics/protocol](https://redis.io/topics/protocol)
1010
/// - Parameter value: The `RESPValue` to encode.
1111
/// - Returns: The encoded value as a collection of bytes.
1212
public func encode(_ value: RESPValue, into buffer: inout ByteBuffer) {

Sources/NIORedis/RESP/RESPValue.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Foundation
22

33
/// A representation of a Redis Serialization Protocol (RESP) primitive value.
44
///
5-
/// See: https://redis.io/topics/protocol
5+
/// See: [https://redis.io/topics/protocol](https://redis.io/topics/protocol)
66
public enum RESPValue {
77
case null
88
case simpleString(String)

Sources/NIORedis/RESP/RESPValueConvertible.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ extension RESPValue: RESPValueConvertible {
1313
self = value
1414
}
1515

16-
/// See `RESPValueConvertible`
16+
/// See `RESPValueConvertible.convertedToRESPValue()`
1717
public func convertedToRESPValue() -> RESPValue {
1818
return self
1919
}
@@ -37,7 +37,7 @@ extension String: RESPValueConvertible {
3737
self = string
3838
}
3939

40-
/// See `RESPValueConvertible`.
40+
/// See `RESPValueConvertible.convertedToRESPValue()`
4141
public func convertedToRESPValue() -> RESPValue {
4242
return .bulkString(Data(self.utf8))
4343
}
@@ -54,7 +54,7 @@ extension FixedWidthInteger {
5454
}
5555
}
5656

57-
/// See `convertedToRESP`.
57+
/// See `RESPValueConvertible.convertedToRESPValue()`
5858
public func convertedToRESPValue() -> RESPValue {
5959
return .bulkString(Data(self.description.utf8))
6060
}
@@ -78,7 +78,7 @@ extension Double: RESPValueConvertible {
7878
self = float
7979
}
8080

81-
/// See `RESPValueConvertible`.
81+
/// See `RESPValueConvertible.convertedToRESPValue()`
8282
public func convertedToRESPValue() -> RESPValue {
8383
return .bulkString(Data(self.description.utf8))
8484
}
@@ -91,7 +91,7 @@ extension Float: RESPValueConvertible {
9191
self = float
9292
}
9393

94-
/// See `RESPValueConvertible`.
94+
/// See `RESPValueConvertible.convertedToRESPValue()`
9595
public func convertedToRESPValue() -> RESPValue {
9696
return .bulkString(Data(self.description.utf8))
9797
}
@@ -103,7 +103,7 @@ extension Data: RESPValueConvertible {
103103
self = data
104104
}
105105

106-
/// See `RESPValueConvertible`.
106+
/// See `RESPValueConvertible.convertedToRESPValue()`
107107
public func convertedToRESPValue() -> RESPValue {
108108
return .bulkString(self)
109109
}
@@ -115,7 +115,7 @@ extension Array: RESPValueConvertible where Element: RESPValueConvertible {
115115
self = array.compactMap { Element($0) }
116116
}
117117

118-
/// See `RESPValueConvertible`.
118+
/// See `RESPValueConvertible.convertedToRESPValue()`
119119
public func convertedToRESPValue() -> RESPValue {
120120
let elements = map { $0.convertedToRESPValue() }
121121
return RESPValue.array(elements)

Sources/NIORedis/RedisConnection.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import NIOConcurrencyHelpers
66
/// let result = connection.send(command: "GET", arguments: ["my_key"]
77
/// // result == EventLoopFuture<RESPValue>
88
///
9-
/// See https://redis.io/commands
9+
/// See [https://redis.io/commands](https://redis.io/commands)
1010
public final class RedisConnection {
1111
/// The `Channel` this connection is associated with.
1212
public let channel: Channel

Sources/NIORedis/RedisPipeline.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import Foundation
1111
/// // results[0].string == Optional("OK")
1212
/// // results[1].int == Optional(4)
1313
///
14-
/// See https://redis.io/topics/pipelining#redis-pipelining
14+
/// See [https://redis.io/topics/pipelining#redis-pipelining](https://redis.io/topics/pipelining#redis-pipelining)
1515
/// - Important: The larger the pipeline queue, the more memory both NIORedis and Redis will use.
1616
public final class RedisPipeline {
1717
/// The number of commands in the pipeline.
@@ -34,7 +34,7 @@ public final class RedisPipeline {
3434

3535
/// Queues the provided command and arguments to be executed when `execute()` is invoked.
3636
/// - Parameters:
37-
/// - command: The command to execute. See https://redis.io/commands
37+
/// - command: The command to execute. See [https://redis.io/commands](https://redis.io/commands)
3838
/// - arguments: The arguments, if any, to send with the command.
3939
/// - Returns: A self-reference for chaining commands.
4040
@discardableResult

0 commit comments

Comments
 (0)