Skip to content

PostgresNIO 1.19.0

Compare
Choose a tag to compare
@fabianfett fabianfett released this 31 Oct 11:40
· 57 commits to main since this release
21473f5

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

SemVer Minor

  • Fix PostgresDecodable inference for RawRepresentable enums (#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)