Expand description
PostgreSQL driver (feature pg) — sqlx PgPool and
PgSqlClient implementing SqlClient.
PgSqlClient::layer is the scoped client layer: it opens the pool when it is built and
closes it when its scope closes, providing both SqlClientService
and the shared PgPool (PgSqlEnv). Its effects need a tokio runtime with its IO
driver (sqlx): run them on id_effect_tokio::TokioRuntime or a TokioExecutor.
§TLS
Connections negotiate TLS through rustls (aws-lc-rs). The mode comes from the URL’s sslmode
(with sslrootcert), or from PgPoolConfig::with_tls_mode /
PgPoolConfig::with_root_cert_file, which override it. The default, PgTlsMode::Prefer,
encrypts when the server offers TLS but checks no certificate and falls back to plaintext, so
it does not stop an active attacker: use PgTlsMode::VerifyFull in production.
See docs/platform/adrs/adr-sql-driver-choice.md.
Structs§
- PgPool
- Shared PostgreSQL pool in the typed environment (derefs to
sqlx::PgPool, which is itself a cheap handle: clone it to hand the pool to an adapter). - PgPool
Config - sqlx PostgreSQL pool sizing, connection string and TLS settings.
- PgSql
Client - PostgreSQL
SqlClientbacked by a sqlx connection pool. - PgSql
Error - Driver-local error wrapper (mostly for pool construction).
- PgSql
Transaction - PostgreSQL transaction handle: its statements run on the transaction’s connection.
Enums§
- PgRoot
Cert - CA certificate(s) a server certificate may chain to (libpq’s
sslrootcert). - PgTls
Mode - Whether and how a connection negotiates TLS (libpq’s
sslmode).
Functions§
- pg_
pool_ from_ config - Create a
PgPoolfromconfig(connects eagerly). A TLS failure (the server refuses TLS underPgTlsMode::Requireor stricter, or its certificate does not verify) isSqlError::TlsFailed, an unreachable serverSqlError::ConnectionFailed. - pg_
pool_ from_ config_ lazy - Lazy pool for unit tests and provider wiring without immediate connect.
- provide_
pg_ pool - A
Layerprovidingpoolas the workspace-widePgPoolcapability. The pool is not closed by the layer (the caller owns it); seePgSqlClient::layerfor a layer that owns its pool. - provide_
pg_ sql_ client - A
Layerprovidingpoolas bothSqlClientService(aPgSqlClient) andPgPool. It neither checks nor closes the pool (the caller owns it); usePgSqlClient::layerfor the scoped variant.