Skip to content

Commit 10797f4

Browse files
authored
Allow backendKeyData to be set (#225)
1 parent fdb1820 commit 10797f4

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

Package.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ let package = Package(
1010
.library(name: "PostgresKit", targets: ["PostgresKit"]),
1111
],
1212
dependencies: [
13-
.package(url: "https://github.com/vapor/postgres-nio.git", from: "1.9.0"),
13+
.package(url: "https://github.com/vapor/postgres-nio.git", from: "1.11.0"),
1414
.package(url: "https://github.com/vapor/sql-kit.git", from: "3.16.0"),
1515
.package(url: "https://github.com/vapor/async-kit.git", from: "1.0.0"),
1616
],

Sources/PostgresKit/PostgresConfiguration.swift

+6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ public struct PostgresConfiguration {
77
public var database: String?
88
public var tlsConfiguration: TLSConfiguration?
99

10+
/// Require connection to provide `BackendKeyData`.
11+
/// For use with Amazon RDS Proxy, this must be set to false.
12+
///
13+
/// - Default: true
14+
public var requireBackendKeyData: Bool = true
15+
1016
/// Optional `search_path` to set on new connections.
1117
public var searchPath: [String]?
1218

Sources/PostgresKit/PostgresConnectionSource.swift

+6-1
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,15 @@ public struct PostgresConnectionSource: ConnectionPoolSource {
2222
case let .success(sslContext): tlsMode = sslContext.map { .require($0) } ?? .disable
2323
case let .failure(error): return eventLoop.makeFailedFuture(error)
2424
}
25+
26+
var connection: PostgresConnection.Configuration.Connection
27+
connection = .init(host: hostname, port: self.configuration._port ?? PostgresConfiguration.ianaPortNumber)
28+
connection.requireBackendKeyData = configuration.requireBackendKeyData
29+
2530
let future = PostgresConnection.connect(
2631
on: eventLoop,
2732
configuration: .init(
28-
connection: .init(host: hostname, port: self.configuration._port ?? PostgresConfiguration.ianaPortNumber),
33+
connection: connection,
2934
authentication: .init(username: self.configuration.username, database: self.configuration.database, password: self.configuration.password),
3035
tls: tlsMode
3136
),

0 commit comments

Comments
 (0)