-
-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Land PostgresClient that is backed by a ConnectionPool as SPI #430
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #430 +/- ##
=======================================
Coverage ? 58.83%
=======================================
Files ? 124
Lines ? 9792
Branches ? 0
=======================================
Hits ? 5761
Misses ? 4031
Partials ? 0
|
/// The server to connect to | ||
/// | ||
/// - Default: localhost | ||
public var host: String = "localhost" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No UDS support?
let pool: Pool | ||
|
||
public init(configuration: Configuration, eventLoopGroup: EventLoopGroup, backgroundLogger: Logger) throws { | ||
let connectionConfig = try PostgresConnection.Configuration(configuration) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variant that uses the singleton ELG?
clientConfig.pool.keepAliveFrequency = .seconds(5) | ||
clientConfig.pool.connectionIdleTimeout = .seconds(15) | ||
|
||
clientConfig.server.host = env("POSTGRES_HOSTNAME") ?? "localhost" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to respect POSTGRES_PORT
too.
|
||
init(keepAliveFrequency: Duration?, logger: Logger) { | ||
self.keepAliveFrequency = keepAliveFrequency | ||
self.query = "SELECT 1;" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be configurable via the corresponding client config field?
93640f8
to
e7022fa
Compare
Crashing compiler toolchain in nightly. Ignore for now. |
|
||
var connectionConfig: PostgresConnection.Configuration | ||
switch config.endpointInfo { | ||
case .bindUnixDomainSocket(let path): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Come to think of it, how about the "existing Channel
" thing too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do we want to use a single Channel for multiple connections. We will need to come up with a custom factory. That is a valuable goal. But not today.
} | ||
} | ||
|
||
public func withConnection<Result>(_ closure: (PostgresConnection) async throws -> Result) async throws -> Result { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doc comments.
Co-authored-by: Gwynne Raskind <gwynne@darkrainfall.org>
No description provided.