feat(v2/postgres): expose pgxpool.Pool for pgx-native operations
What
Switches the postgres.Client internals from stdlib.OpenDB to pgxpool.Pool + stdlib.OpenDBFromPool, and exposes the pool via a new Pool() *pgxpool.Pool method.
Why
The previous implementation used stdlib.OpenDB(*pgx.ConnConfig), which creates a *sql.DB backed by a simple per-request connection — not a proper pool. This meant:
- Connection pooling was handled by
database/sql's own (minimal) pool, not pgx's purpose-builtpgxpool - pgx-native features were completely inaccessible: COPY FROM/TO, batch queries, named prepared statements, LISTEN/NOTIFY
Services needing bulk inserts, high-throughput batching, or event-driven patterns had no path forward within the labkit abstraction.
Changes
client.go
- Internals:
stdlib.OpenDB→pgxpool.NewWithConfig+stdlib.OpenDBFromPool - New method:
Pool() *pgxpool.Pool— returns nil beforeStart - New config field:
MinConns int— keep N connections warm (maps topgxpool.Config.MinConns) - Deprecated config field:
MaxIdleConns— not meaningful with pgxpool; documented with clear guidance on alternatives
Backward compatibility
-
DB()still returns*sql.DB— existing consumers unchanged - All existing
Configfields still accepted;MaxConns,ConnMaxLifetime,ConnMaxIdleTimemap to their pgxpool equivalents -
MaxIdleConnsis silently ignored (was previouslydb.SetMaxIdleConns)
README.md — new file with capability comparison table, both access paths with code examples, PgBouncer guidance, and testing patterns
doc.go — updated to document both access paths
example_test.go — new file showing Pool() and MinConns
client_test.go — TestPool_NilBeforeStart added