Skip to content

Add Distributed Tracing support #177

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.DS_Store
/.build
.build
.swiftpm
/Packages
xcuserdata/
DerivedData/
Expand All @@ -10,4 +11,4 @@ DerivedData/
Package.resolved
.benchmarkBaselines/
.swift-version
.docc-build
.docc-build
5 changes: 4 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ let package = Package(
],
traits: [
.trait(name: "ServiceLifecycleSupport"),
.default(enabledTraits: ["ServiceLifecycleSupport"]),
.trait(name: "DistributedTracingSupport"),
.default(enabledTraits: ["ServiceLifecycleSupport", "DistributedTracingSupport"]),
],
dependencies: [
.package(url: "https://github.com/apple/swift-atomics.git", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-collections.git", from: "1.1.4"),
.package(url: "https://github.com/apple/swift-log.git", from: "1.6.3"),
.package(url: "https://github.com/apple/swift-distributed-tracing.git", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-nio.git", from: "2.81.0"),
.package(url: "https://github.com/apple/swift-nio-ssl.git", from: "2.29.0"),
.package(url: "https://github.com/apple/swift-nio-transport-services.git", from: "1.23.0"),
Expand All @@ -39,6 +41,7 @@ let package = Package(
.byName(name: "_ValkeyConnectionPool"),
.product(name: "DequeModule", package: "swift-collections"),
.product(name: "Logging", package: "swift-log"),
.product(name: "Tracing", package: "swift-distributed-tracing", condition: .when(traits: ["DistributedTracingSupport"])),
.product(name: "NIOCore", package: "swift-nio"),
.product(name: "NIOPosix", package: "swift-nio"),
.product(name: "NIOSSL", package: "swift-nio-ssl"),
Expand Down
14 changes: 14 additions & 0 deletions Sources/Valkey/Commands/BitmapCommands.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ public struct BITCOUNT: ValkeyCommand {
}
public typealias Response = Int

@inlinable public static var name: String { "BITCOUNT" }

public var key: ValkeyKey
public var range: Range?

Expand Down Expand Up @@ -247,6 +249,8 @@ public struct BITFIELD: ValkeyCommand {
}
public typealias Response = RESPToken.Array

@inlinable public static var name: String { "BITFIELD" }

public var key: ValkeyKey
public var operations: [Operation]

Expand Down Expand Up @@ -287,6 +291,8 @@ public struct BITFIELDRO: ValkeyCommand {
}
public typealias Response = [Int]

@inlinable public static var name: String { "BITFIELD_RO" }

public var key: ValkeyKey
public var getBlocks: [GetBlock]

Expand Down Expand Up @@ -328,6 +334,8 @@ public struct BITOP: ValkeyCommand {
}
public typealias Response = Int

@inlinable public static var name: String { "BITOP" }

public var operation: Operation
public var destkey: ValkeyKey
public var keys: [ValkeyKey]
Expand Down Expand Up @@ -405,6 +413,8 @@ public struct BITPOS: ValkeyCommand {
}
public typealias Response = Int

@inlinable public static var name: String { "BITPOS" }

public var key: ValkeyKey
public var bit: Int
public var range: Range?
Expand All @@ -429,6 +439,8 @@ public struct BITPOS: ValkeyCommand {
public struct GETBIT: ValkeyCommand {
public typealias Response = Int

@inlinable public static var name: String { "GETBIT" }

public var key: ValkeyKey
public var offset: Int

Expand All @@ -451,6 +463,8 @@ public struct GETBIT: ValkeyCommand {
public struct SETBIT: ValkeyCommand {
public typealias Response = Int

@inlinable public static var name: String { "SETBIT" }

public var key: ValkeyKey
public var offset: Int
public var value: Int
Expand Down
64 changes: 64 additions & 0 deletions Sources/Valkey/Commands/ClusterCommands.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public enum CLUSTER {
/// Assigns new hash slots to a node.
@_documentation(visibility: internal)
public struct ADDSLOTS: ValkeyCommand {
@inlinable public static var name: String { "CLUSTER ADDSLOTS" }

public var slots: [Int]

@inlinable public init(slots: [Int]) {
Expand Down Expand Up @@ -62,6 +64,8 @@ public enum CLUSTER {
endSlot.encode(into: &commandEncoder)
}
}
@inlinable public static var name: String { "CLUSTER ADDSLOTSRANGE" }

public var ranges: [Range]

@inlinable public init(ranges: [Range]) {
Expand All @@ -78,6 +82,8 @@ public enum CLUSTER {
public struct BUMPEPOCH: ValkeyCommand {
public typealias Response = ByteBuffer

@inlinable public static var name: String { "CLUSTER BUMPEPOCH" }

@inlinable public init() {
}

Expand All @@ -91,6 +97,8 @@ public enum CLUSTER {
public struct COUNTFAILUREREPORTS<NodeId: RESPStringRenderable>: ValkeyCommand {
public typealias Response = Int

@inlinable public static var name: String { "CLUSTER COUNT-FAILURE-REPORTS" }

public var nodeId: NodeId

@inlinable public init(nodeId: NodeId) {
Expand All @@ -107,6 +115,8 @@ public enum CLUSTER {
public struct COUNTKEYSINSLOT: ValkeyCommand {
public typealias Response = Int

@inlinable public static var name: String { "CLUSTER COUNTKEYSINSLOT" }

public var slot: Int

@inlinable public init(slot: Int) {
Expand All @@ -121,6 +131,8 @@ public enum CLUSTER {
/// Sets hash slots as unbound for a node.
@_documentation(visibility: internal)
public struct DELSLOTS: ValkeyCommand {
@inlinable public static var name: String { "CLUSTER DELSLOTS" }

public var slots: [Int]

@inlinable public init(slots: [Int]) {
Expand Down Expand Up @@ -155,6 +167,8 @@ public enum CLUSTER {
endSlot.encode(into: &commandEncoder)
}
}
@inlinable public static var name: String { "CLUSTER DELSLOTSRANGE" }

public var ranges: [Range]

@inlinable public init(ranges: [Range]) {
Expand Down Expand Up @@ -184,6 +198,8 @@ public enum CLUSTER {
}
}
}
@inlinable public static var name: String { "CLUSTER FAILOVER" }

public var options: Options?

@inlinable public init(options: Options? = nil) {
Expand All @@ -198,6 +214,8 @@ public enum CLUSTER {
/// Deletes all slots information from a node.
@_documentation(visibility: internal)
public struct FLUSHSLOTS: ValkeyCommand {
@inlinable public static var name: String { "CLUSTER FLUSHSLOTS" }

@inlinable public init() {
}

Expand All @@ -209,6 +227,8 @@ public enum CLUSTER {
/// Removes a node from the nodes table.
@_documentation(visibility: internal)
public struct FORGET<NodeId: RESPStringRenderable>: ValkeyCommand {
@inlinable public static var name: String { "CLUSTER FORGET" }

public var nodeId: NodeId

@inlinable public init(nodeId: NodeId) {
Expand All @@ -225,6 +245,8 @@ public enum CLUSTER {
public struct GETKEYSINSLOT: ValkeyCommand {
public typealias Response = RESPToken.Array

@inlinable public static var name: String { "CLUSTER GETKEYSINSLOT" }

public var slot: Int
public var count: Int

Expand All @@ -243,6 +265,8 @@ public enum CLUSTER {
public struct HELP: ValkeyCommand {
public typealias Response = RESPToken.Array

@inlinable public static var name: String { "CLUSTER HELP" }

@inlinable public init() {
}

Expand All @@ -256,6 +280,8 @@ public enum CLUSTER {
public struct INFO: ValkeyCommand {
public typealias Response = ByteBuffer

@inlinable public static var name: String { "CLUSTER INFO" }

@inlinable public init() {
}

Expand All @@ -269,6 +295,8 @@ public enum CLUSTER {
public struct KEYSLOT<Key: RESPStringRenderable>: ValkeyCommand {
public typealias Response = Int

@inlinable public static var name: String { "CLUSTER KEYSLOT" }

public var key: Key

@inlinable public init(_ key: Key) {
Expand All @@ -285,6 +313,8 @@ public enum CLUSTER {
public struct LINKS: ValkeyCommand {
public typealias Response = RESPToken.Array

@inlinable public static var name: String { "CLUSTER LINKS" }

@inlinable public init() {
}

Expand All @@ -296,6 +326,8 @@ public enum CLUSTER {
/// Forces a node to handshake with another node.
@_documentation(visibility: internal)
public struct MEET<Ip: RESPStringRenderable>: ValkeyCommand {
@inlinable public static var name: String { "CLUSTER MEET" }

public var ip: Ip
public var port: Int
public var clusterBusPort: Int?
Expand All @@ -316,6 +348,8 @@ public enum CLUSTER {
public struct MYID: ValkeyCommand {
public typealias Response = ByteBuffer

@inlinable public static var name: String { "CLUSTER MYID" }

@inlinable public init() {
}

Expand All @@ -329,6 +363,8 @@ public enum CLUSTER {
public struct MYSHARDID: ValkeyCommand {
public typealias Response = ByteBuffer

@inlinable public static var name: String { "CLUSTER MYSHARDID" }

@inlinable public init() {
}

Expand All @@ -342,6 +378,8 @@ public enum CLUSTER {
public struct NODES: ValkeyCommand {
public typealias Response = ByteBuffer

@inlinable public static var name: String { "CLUSTER NODES" }

@inlinable public init() {
}

Expand All @@ -355,6 +393,8 @@ public enum CLUSTER {
public struct REPLICAS<NodeId: RESPStringRenderable>: ValkeyCommand {
public typealias Response = RESPToken.Array

@inlinable public static var name: String { "CLUSTER REPLICAS" }

public var nodeId: NodeId

@inlinable public init(nodeId: NodeId) {
Expand All @@ -369,6 +409,8 @@ public enum CLUSTER {
/// Configure a node as replica of a primary node.
@_documentation(visibility: internal)
public struct REPLICATE<NodeId: RESPStringRenderable>: ValkeyCommand {
@inlinable public static var name: String { "CLUSTER REPLICATE" }

public var nodeId: NodeId

@inlinable public init(nodeId: NodeId) {
Expand Down Expand Up @@ -398,6 +440,8 @@ public enum CLUSTER {
}
}
}
@inlinable public static var name: String { "CLUSTER RESET" }

public var resetType: ResetType?

@inlinable public init(resetType: ResetType? = nil) {
Expand All @@ -412,6 +456,8 @@ public enum CLUSTER {
/// Forces a node to save the cluster configuration to disk.
@_documentation(visibility: internal)
public struct SAVECONFIG: ValkeyCommand {
@inlinable public static var name: String { "CLUSTER SAVECONFIG" }

@inlinable public init() {
}

Expand All @@ -423,6 +469,8 @@ public enum CLUSTER {
/// Sets the configuration epoch for a new node.
@_documentation(visibility: internal)
public struct SETCONFIGEPOCH: ValkeyCommand {
@inlinable public static var name: String { "CLUSTER SET-CONFIG-EPOCH" }

public var configEpoch: Int

@inlinable public init(configEpoch: Int) {
Expand Down Expand Up @@ -463,6 +511,8 @@ public enum CLUSTER {
}
}
}
@inlinable public static var name: String { "CLUSTER SETSLOT" }

public var slot: Int
public var subcommand: Subcommand
public var timeout: Int?
Expand All @@ -481,6 +531,8 @@ public enum CLUSTER {
/// Returns the mapping of cluster slots to shards.
@_documentation(visibility: internal)
public struct SHARDS: ValkeyCommand {
@inlinable public static var name: String { "CLUSTER SHARDS" }

@inlinable public init() {
}

Expand All @@ -494,6 +546,8 @@ public enum CLUSTER {
public struct SLAVES<NodeId: RESPStringRenderable>: ValkeyCommand {
public typealias Response = RESPToken.Array

@inlinable public static var name: String { "CLUSTER SLAVES" }

public var nodeId: NodeId

@inlinable public init(nodeId: NodeId) {
Expand Down Expand Up @@ -588,6 +642,8 @@ public enum CLUSTER {
}
public typealias Response = RESPToken.Array

@inlinable public static var name: String { "CLUSTER SLOT-STATS" }

public var filter: Filter

@inlinable public init(filter: Filter) {
Expand All @@ -604,6 +660,8 @@ public enum CLUSTER {
public struct SLOTS: ValkeyCommand {
public typealias Response = RESPToken.Array

@inlinable public static var name: String { "CLUSTER SLOTS" }

@inlinable public init() {
}

Expand All @@ -617,6 +675,8 @@ public enum CLUSTER {
/// Signals that a cluster client is following an -ASK redirect.
@_documentation(visibility: internal)
public struct ASKING: ValkeyCommand {
@inlinable public static var name: String { "ASKING" }

@inlinable public init() {
}

Expand All @@ -628,6 +688,8 @@ public struct ASKING: ValkeyCommand {
/// Enables read-only queries for a connection to a Valkey replica node.
@_documentation(visibility: internal)
public struct READONLY: ValkeyCommand {
@inlinable public static var name: String { "READONLY" }

@inlinable public init() {
}

Expand All @@ -639,6 +701,8 @@ public struct READONLY: ValkeyCommand {
/// Enables read-write queries for a connection to a Valkey replica node.
@_documentation(visibility: internal)
public struct READWRITE: ValkeyCommand {
@inlinable public static var name: String { "READWRITE" }

@inlinable public init() {
}

Expand Down
Loading
Loading