bestool-postgres
PostgreSQL connection-pool utilities shared by the BES tooling. Wraps
tokio-postgres with mobc pooling and rustls TLS, and adds a few
quality-of-life helpers we want everywhere.
What's in it
PgPool::create_pool(url, application_name)— build a pool from a libpq connection URL. Handles a few things that baretokio-postgresdoes not:- Unix-socket connection strings (
postgresql:///db?host=/var/run/postgresql, percent-encoded host, or empty host with auto-detect). sslmode=preferfallback to disabled TLS when the server refuses.- Interactive password prompt (via
rpassword) if the URL has no password and the server returns an auth error.
- Unix-socket connection strings (
pg_interval::Interval— aDurationnewtype that implementsToSqlfor PostgreSQL'sINTERVALtype.stringify::postgres_to_json_value— best-effort row-cell →serde_json::Valueconversion across the common PG types.text_cast— extract any column as its text representation regardless of declared type, useful for generic dump/inspect tools.error— shared error types and amiette-friendly diagnostic style.
Use
[]
= "1"
use create_pool;
# async
Scope
This crate exists to support BES tools (alertd, psql, bestool itself); it is deliberately opinionated rather than a general-purpose pool. That said, the helpers are reusable, and patches that broaden them sensibly are welcome.
License
GPL-3.0-or-later.