Skip to content

Commit

Permalink
Merge branch 'add-port-static' into 'master'
Browse files Browse the repository at this point in the history
Add static property for default RedisConnection port

See merge request Mordil/swift-redis-nio-client!51
  • Loading branch information
Mordil committed Jun 12, 2019
2 parents 30733de + 73b3f5d commit 531a7d4
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ and run the following command: `swift package resolve`
import RedisNIO

let connection = Redis.makeConnection(
to: try .init(ipAddress: "127.0.0.1", port: 6379),
to: try .init(ipAddress: "127.0.0.1", port: RedisConnection.defaultPort),
password: "my_pass"
).wait()

Expand Down
2 changes: 1 addition & 1 deletion Sources/RedisNIO/Redis.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ extension Redis {
///
/// let elg = MultiThreadedEventLoopGroup(numberOfThreads: 3)
/// let connection = Redis.makeConnection(
/// to: .init(ipAddress: "127.0.0.1", port: 6379),
/// to: .init(ipAddress: "127.0.0.1", port: RedisConnection.defaultPort),
/// using: elg,
/// password: "my_pass"
/// )
Expand Down
2 changes: 2 additions & 0 deletions Sources/RedisNIO/RedisClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ private let loggingKeyID = "RedisConnection"
///
/// See `RedisClient`
public final class RedisConnection: RedisClient {
public static let defaultPort = 6379

private enum ConnectionState {
case open
case closed
Expand Down
5 changes: 4 additions & 1 deletion Tests/RedisNIOTests/Utilities/RedisConnection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ extension Redis {
static func makeConnection() throws -> EventLoopFuture<RedisConnection> {
let env = ProcessInfo.processInfo.environment
return Redis.makeConnection(
to: try .makeAddressResolvingHost(env["REDIS_URL"] ?? "127.0.0.1", port: 6379),
to: try .makeAddressResolvingHost(
env["REDIS_URL"] ?? "127.0.0.1",
port: RedisConnection.defaultPort
),
password: env["REDIS_PW"]
)
}
Expand Down

0 comments on commit 531a7d4

Please sign in to comment.