Skip to content

Commit 97a62ce

Browse files
committed
DatabaseHost: switch to SocketAddress instead of plain host+port
1 parent 663cd26 commit 97a62ce

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

Sources/MySQLBridge/Extensions/DatabaseHost+Initialization.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ extension DatabaseHost {
1515
let port = Int(ProcessInfo.processInfo.environment["MYSQL_PORT"] ?? "5432")
1616
let user = ProcessInfo.processInfo.environment["MYSQL_USER"] ?? "postgres"
1717
let pwd = ProcessInfo.processInfo.environment["MYSQL_PWD"]
18-
return .init(hostname: host, username: user, password: pwd, port: port ?? 5432, tlsConfiguration: nil)
18+
return .init(hostname: host, port: port ?? 5432, username: user, password: pwd, tlsConfiguration: nil)
1919
}
2020

2121
public init?(url: URL) {
@@ -42,6 +42,7 @@ extension DatabaseHost {
4242
tlsConfiguration = .forClient()
4343
}
4444

45-
self.init(hostname: hostname, username: username, password: password, port: port, tlsConfiguration: tlsConfiguration)
45+
self.init(hostname: hostname, port: port, username: username, password: password, tlsConfiguration: tlsConfiguration)
46+
}
4647
}
4748
}

Sources/MySQLBridge/MySQLConnectionSource.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public struct MySQLConnectionSource: BridgesPoolSource {
1818
public func makeConnection(logger: Logger, on eventLoop: EventLoop) -> EventLoopFuture<MySQLConnection> {
1919
let address: SocketAddress
2020
do {
21-
address = try SocketAddress.makeAddressResolvingHost(self.db.host.hostname, port: self.db.host.port)
21+
address = try self.db.host.address()
2222
} catch {
2323
return eventLoop.makeFailedFuture(error)
2424
}

0 commit comments

Comments
 (0)