Skip to content
Merged
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
16 changes: 0 additions & 16 deletions Sources/Valkey/Cluster/ValkeyNodeDescription.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,6 @@ package struct ValkeyNodeDescription: Identifiable, Hashable, Sendable {
ValkeyNodeID(endpoint: self.endpoint, port: self.port)
}

/// The hostname of the Valkey node, if available.
///
/// This may be `nil` if the node is only known by IP address.
package var host: String?

/// The IP address of the Valkey node, if available.
///
/// This may be `nil` if the node is only known by hostname.
package var ip: String?

/// The network endpoint (hostname or IP) used to connect to this node.
///
/// This property is required and is used as part of the node's unique identifier.
Expand All @@ -59,8 +49,6 @@ package struct ValkeyNodeDescription: Identifiable, Hashable, Sendable {
/// - Parameter description: A value conforming to `ValkeyNodeDescriptionProtocol` that provides
/// the necessary node information.
package init(description: any ValkeyNodeDescriptionProtocol) {
self.host = description.host
self.ip = description.ip
self.endpoint = description.endpoint
self.port = description.port
}
Expand All @@ -74,8 +62,6 @@ package struct ValkeyNodeDescription: Identifiable, Hashable, Sendable {
/// - Note: If both TLS and regular ports are available, the TLS port takes precedence.
/// If no port is specified, the default Valkey port (6379) is used.
package init(description: ValkeyClusterDescription.Node) {
self.host = description.hostname
self.ip = description.ip
self.endpoint = description.endpoint
self.port = description.tlsPort ?? description.port ?? 6379
}
Expand All @@ -86,8 +72,6 @@ package struct ValkeyNodeDescription: Identifiable, Hashable, Sendable {
///
/// - Parameter redirectionError: A `ValkeyClusterRedirectionError` instance.
package init(redirectionError: ValkeyClusterRedirectionError) {
self.host = nil
self.ip = nil
self.endpoint = redirectionError.endpoint
self.port = redirectionError.port
}
Expand Down
14 changes: 2 additions & 12 deletions Sources/Valkey/Cluster/ValkeyNodeDescriptionProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,10 @@ import NIOCore
/// The protocol requires both hostname and IP address properties to be available, though either may be nil
/// depending on how the node is identified. The ``endpoint`` property provides the actual connection target.
public protocol ValkeyNodeDescriptionProtocol: Sendable, Equatable {
/// The node's host name, if available.
///
/// This may be nil if the node is identified solely by IP address.
var host: String? { get }

/// The node's IP address, if available.
///
/// This may be nil if the node is identified solely by hostname.
var ip: String? { get }

/// The node's connection endpoint string.
///
/// This should typically be the ``host`` if the node has a routable hostname,
/// otherwise it should be the ``ip``. This property is used to establish
/// This should typically be the hostname if the node has a routable hostname,
/// otherwise it should be the ip. This property is used to establish
/// network connections to the node.
var endpoint: String { get }

Expand Down
23 changes: 3 additions & 20 deletions Sources/Valkey/Cluster/ValkeyNodeDiscovery.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,33 +43,16 @@ public protocol ValkeyNodeDiscovery: Sendable {
public struct ValkeyStaticNodeDiscovery: ValkeyNodeDiscovery {
/// A description of a single node in the Valkey cluster.
public struct NodeDescription: ValkeyNodeDescriptionProtocol {
public var host: String?
public var ip: String?
public var endpoint: String
public var port: Int

/// Initializes a `NodeDescription` with a host and optional IP.
///
/// - Parameters:
/// - host: The host name of the node.
/// - ip: The optional IP address of the node.
/// - endpoint: The node endpoint.
/// - port: The port number the node listens on (default is 6379).
public init(host: String, ip: String? = nil, port: Int = 6379) {
self.host = host
self.ip = ip
self.endpoint = host
self.port = port
}

/// Initializes a `NodeDescription` with an IP address.
///
/// - Parameters:
/// - ip: The IP address of the node.
/// - port: The port number the node listens on (default is 6379).
public init(ip: String, port: Int = 6379) {
self.host = nil
self.ip = ip
self.endpoint = ip
public init(endpoint: String, port: Int = 6379) {
self.endpoint = endpoint
self.port = port
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ struct ClusterIntegrationTests {
) async throws -> T {
let client = ValkeyClusterClient(
clientConfiguration: nodeClientConfiguration,
nodeDiscovery: ValkeyStaticNodeDiscovery(nodeAddresses.map { .init(host: $0.host, port: $0.port) }),
nodeDiscovery: ValkeyStaticNodeDiscovery(nodeAddresses.map { .init(endpoint: $0.host, port: $0.port) }),
logger: logger
)

Expand Down
Loading