Skip to content

Commit 1af722d

Browse files
authored
Rename pipeline(_:) to execute(_:), send(command:), execute(_:) (#163)
* pipeline->execute, send-> execute Signed-off-by: Adam Fowler <[email protected]> * Fixup remnants Signed-off-by: Adam Fowler <[email protected]> * Rename command label from execute Signed-off-by: Adam Fowler <[email protected]> * doc changes Signed-off-by: Adam Fowler <[email protected]> * Update pipelining docc markdown Signed-off-by: Adam Fowler <[email protected]> * Add overview Signed-off-by: Adam Fowler <[email protected]> * Fix error in docs, edit execute(_:) comment Signed-off-by: Adam Fowler <[email protected]> * Edited pipelining text in README slightly Signed-off-by: Adam Fowler <[email protected]> * formatting Signed-off-by: Adam Fowler <[email protected]> --------- Signed-off-by: Adam Fowler <[email protected]>
1 parent 3c6795b commit 1af722d

34 files changed

+493
-522
lines changed

Package.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ let package = Package(
2929
.package(url: "https://github.com/apple/swift-nio-ssl.git", from: "2.29.0"),
3030
.package(url: "https://github.com/apple/swift-nio-transport-services.git", from: "1.23.0"),
3131
.package(url: "https://github.com/swift-server/swift-service-lifecycle.git", from: "2.8.0"),
32+
33+
//.package(url: "https://github.com/swiftlang/swift-docc-plugin.git", from: "1.4.5"),
3234
],
3335
targets: [
3436
.target(

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ All the Valkey commands are in the Commands folder of the Valkey target. These a
3737

3838
### Pipelining commands
3939

40-
In some cases it is desirable to send multiple commands at one time, without waiting for the response after each command. This is called pipelining. You can do this using the function `pipeline(_:)`. This takes a parameter pack of commands and returns a parameter pack with the responses once all the commands have executed.
40+
In some cases it is desirable to send multiple commands at one time, without waiting for the response after each command. This is called pipelining. You can do this using the function `execute(_:)`. This function takes multiple commands in the form of a parameter pack. It sends all the commands off at the same time and once it has received all the responses, returns a parameter pack containing the responses.
4141

4242
```swift
43-
let (setResponse, getResponse) = await connection.pipeline(
43+
let (setResponse, getResponse) = await connection.execute(
4444
SET(key: "MyKey", value: "TestString"),
4545
GET(key: "MyKey")
4646
)

Sources/Valkey/Cluster/ValkeyClusterClient.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public final class ValkeyClusterClient: Sendable {
151151
/// - `ValkeyClusterError.clientRequestCancelled` if the request is cancelled
152152
/// - Other errors if the command execution or parsing fails
153153
@inlinable
154-
public func send<Command: ValkeyCommand>(command: Command) async throws -> Command.Response {
154+
public func execute<Command: ValkeyCommand>(_ command: Command) async throws -> Command.Response {
155155
let hashSlots = command.keysAffected.map { HashSlot(key: $0) }
156156
var clientSelector: () async throws -> ValkeyNodeClient = {
157157
try await self.nodeClient(for: hashSlots)
@@ -160,7 +160,7 @@ public final class ValkeyClusterClient: Sendable {
160160
while !Task.isCancelled {
161161
do {
162162
let client = try await clientSelector()
163-
return try await client.send(command: command)
163+
return try await client.execute(command)
164164
} catch ValkeyClusterError.noNodeToTalkTo {
165165
// TODO: Rerun node discovery!
166166
} catch let error as ValkeyClientError where error.errorCode == .commandError {
@@ -581,7 +581,7 @@ public final class ValkeyClusterClient: Sendable {
581581
try await withThrowingTaskGroup(of: (ValkeyClusterDescription, ValkeyNodeID).self) { taskGroup in
582582
for voter in voters {
583583
taskGroup.addTask {
584-
(try await voter.client.send(command: CLUSTER.SHARDS()), voter.nodeID)
584+
(try await voter.client.execute(CLUSTER.SHARDS()), voter.nodeID)
585585
}
586586
}
587587

@@ -625,7 +625,7 @@ public final class ValkeyClusterClient: Sendable {
625625

626626
for voter in actions.voters {
627627
taskGroup.addTask {
628-
(try await voter.client.send(command: CLUSTER.SHARDS()), voter.nodeID)
628+
(try await voter.client.execute(CLUSTER.SHARDS()), voter.nodeID)
629629
}
630630
}
631631

Sources/Valkey/Commands/BitmapCommands.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ extension ValkeyClientProtocol {
480480
/// - Response: [Integer]: The number of bits set to 1.
481481
@inlinable
482482
public func bitcount(_ key: ValkeyKey, range: BITCOUNT.Range? = nil) async throws -> Int {
483-
try await send(command: BITCOUNT(key, range: range))
483+
try await execute(BITCOUNT(key, range: range))
484484
}
485485

486486
/// Performs arbitrary bitfield integer operations on strings.
@@ -494,7 +494,7 @@ extension ValkeyClientProtocol {
494494
@inlinable
495495
@discardableResult
496496
public func bitfield(_ key: ValkeyKey, operations: [BITFIELD.Operation] = []) async throws -> RESPToken.Array {
497-
try await send(command: BITFIELD(key, operations: operations))
497+
try await execute(BITFIELD(key, operations: operations))
498498
}
499499

500500
/// Performs arbitrary read-only bitfield integer operations on strings.
@@ -505,7 +505,7 @@ extension ValkeyClientProtocol {
505505
/// - Response: [Array]: The result of the subcommand at the same position
506506
@inlinable
507507
public func bitfieldRo(_ key: ValkeyKey, getBlocks: [BITFIELDRO.GetBlock] = []) async throws -> [Int] {
508-
try await send(command: BITFIELDRO(key, getBlocks: getBlocks))
508+
try await execute(BITFIELDRO(key, getBlocks: getBlocks))
509509
}
510510

511511
/// Performs bitwise operations on multiple strings, and stores the result.
@@ -517,7 +517,7 @@ extension ValkeyClientProtocol {
517517
@inlinable
518518
@discardableResult
519519
public func bitop(operation: BITOP.Operation, destkey: ValkeyKey, keys: [ValkeyKey]) async throws -> Int {
520-
try await send(command: BITOP(operation: operation, destkey: destkey, keys: keys))
520+
try await execute(BITOP(operation: operation, destkey: destkey, keys: keys))
521521
}
522522

523523
/// Finds the first set (1) or clear (0) bit in a string.
@@ -532,7 +532,7 @@ extension ValkeyClientProtocol {
532532
/// * -1: In case the `bit` argument is 1 and the string is empty or composed of just zero bytes.
533533
@inlinable
534534
public func bitpos(_ key: ValkeyKey, bit: Int, range: BITPOS.Range? = nil) async throws -> Int {
535-
try await send(command: BITPOS(key, bit: bit, range: range))
535+
try await execute(BITPOS(key, bit: bit, range: range))
536536
}
537537

538538
/// Returns a bit value by offset.
@@ -543,7 +543,7 @@ extension ValkeyClientProtocol {
543543
/// - Response: The bit value stored at offset.
544544
@inlinable
545545
public func getbit(_ key: ValkeyKey, offset: Int) async throws -> Int {
546-
try await send(command: GETBIT(key, offset: offset))
546+
try await execute(GETBIT(key, offset: offset))
547547
}
548548

549549
/// Sets or clears the bit at offset of the string value. Creates the key if it doesn't exist.
@@ -555,7 +555,7 @@ extension ValkeyClientProtocol {
555555
@inlinable
556556
@discardableResult
557557
public func setbit(_ key: ValkeyKey, offset: Int, value: Int) async throws -> Int {
558-
try await send(command: SETBIT(key, offset: offset, value: value))
558+
try await execute(SETBIT(key, offset: offset, value: value))
559559
}
560560

561561
}

0 commit comments

Comments
 (0)