Skip to content

Commit 531a7d4

Browse files
committed
Merge branch 'add-port-static' into 'master'
Add static property for default RedisConnection port See merge request Mordil/swift-redis-nio-client!51
2 parents 30733de + 73b3f5d commit 531a7d4

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ and run the following command: `swift package resolve`
3838
import RedisNIO
3939

4040
let connection = Redis.makeConnection(
41-
to: try .init(ipAddress: "127.0.0.1", port: 6379),
41+
to: try .init(ipAddress: "127.0.0.1", port: RedisConnection.defaultPort),
4242
password: "my_pass"
4343
).wait()
4444

Sources/RedisNIO/Redis.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ extension Redis {
6464
///
6565
/// let elg = MultiThreadedEventLoopGroup(numberOfThreads: 3)
6666
/// let connection = Redis.makeConnection(
67-
/// to: .init(ipAddress: "127.0.0.1", port: 6379),
67+
/// to: .init(ipAddress: "127.0.0.1", port: RedisConnection.defaultPort),
6868
/// using: elg,
6969
/// password: "my_pass"
7070
/// )

Sources/RedisNIO/RedisClient.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ private let loggingKeyID = "RedisConnection"
5656
///
5757
/// See `RedisClient`
5858
public final class RedisConnection: RedisClient {
59+
public static let defaultPort = 6379
60+
5961
private enum ConnectionState {
6062
case open
6163
case closed

Tests/RedisNIOTests/Utilities/RedisConnection.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ extension Redis {
1919
static func makeConnection() throws -> EventLoopFuture<RedisConnection> {
2020
let env = ProcessInfo.processInfo.environment
2121
return Redis.makeConnection(
22-
to: try .makeAddressResolvingHost(env["REDIS_URL"] ?? "127.0.0.1", port: 6379),
22+
to: try .makeAddressResolvingHost(
23+
env["REDIS_URL"] ?? "127.0.0.1",
24+
port: RedisConnection.defaultPort
25+
),
2326
password: env["REDIS_PW"]
2427
)
2528
}

0 commit comments

Comments
 (0)