PostgresNIO 1.19.0
What is better than one PostgresConnection? Multiple PostgresConnections! This is why PostgresNIO now features an experimental
PostgresClient that is backed by a new ConnectionPool implementation.
The new PostgresClient and its underlying ConnectionPool implementation are large new features that are in an early experimental stage. We encourage PostgresNIO users to try them and provide feedback. The implementation is so new, and the feature scope so large, that we don't make any API stability promises for PostgresClient yet; it is therefore exposed as an SPI import.
If you want to start playing with the new PostgresClient, start with a pattern like this:
@_spi(ConnectionPool) import PostgresNIO
let client = PostgresClient(configuration: configuration, logger: logger)
await withTaskGroup(of: Void.self) {
taskGroup.addTask {
// 🚨 The PostgresClient only works if its `run()` method is executed in a long-running task.
// This ensures that all background work shall be executed in a way that plays
// nicely with structured concurrency.
client.run()
}
taskGroup.addTask {
client.withConnection { connection in
do {
let rows = try await connection.query("SELECT userID, name, age FROM users;")
for try await (userID, name, age) in rows.decode((UUID, String, Int).self) {
// do something with the values
}
} catch {
// handle errors
}
}
}
}We are currently working with the ServiceLifecycle maintainers to enable simple integration (however, we do not intend to depend on ServiceLifecycle directly).
If you run into any problems, please open a new Issue.
SPI(ConnectionPool) changes
- Add new
ConnectionPoolModule,PostgresClient(#412, #416, #417, #418, #419, #420, #421, #422, #424, #425, #426, #427, #428, #429, #430)
SemVer Minor
- Fix
PostgresDecodableinference forRawRepresentableenums (#423, patch credit to @MahdiBM) - Remove warn-concurrency warnings (#408)
- Update minimum Swift requirement to 5.7 (#414)
Other Changes
- Update SSWG Graduation Level (#409)