Versions in this module Expand all Collapse all v1 v1.0.0 Jul 16, 2026 Changes in this version + const DefaultAcquireTimeout + const DefaultConnectTimeout + const DefaultPingTimeout + const DefaultShutdownTimeout + const DefaultTransactionCleanupTimeout + var ErrAcquireTimeout = errors.New("postgres: acquire timeout") + var ErrHealthTimeout = errors.New("postgres: health check timeout") + var ErrNilTransactionCallback = errors.New("postgres: transaction callback is nil") + var ErrPoolClosed = errors.New("postgres: pool closed") + var ErrPoolExhausted = errors.New("postgres: pool exhausted") + var ErrShutdownTimeout = errors.New("postgres: shutdown timeout") + func IsCancellation(err error) bool + func IsCheckViolation(err error) bool + func IsConnectivity(err error) bool + func IsDeadlock(err error) bool + func IsExclusionViolation(err error) bool + func IsForeignKeyViolation(err error) bool + func IsKind(err error, kind ErrorKind) bool + func IsLockUnavailable(err error) bool + func IsPoolExhaustion(err error) bool + func IsQueryCanceled(err error) bool + func IsRetryable(err error) bool + func IsSerializationFailure(err error) bool + func IsTimeout(err error) bool + func IsUniqueViolation(err error) bool + func RunSavepoint(ctx context.Context, parent pgx.Tx, cleanupTimeout time.Duration, ...) error + func RunSavepointWithOptions(ctx context.Context, parent pgx.Tx, options SavepointOptions, ...) (err error) + func RunTransaction(ctx context.Context, beginner Beginner, options TransactionOptions, ...) (err error) + func SQLState(err error) (string, bool) + type Beginner interface + BeginTx func(context.Context, pgx.TxOptions) (pgx.Tx, error) + type Config struct + AcquireTimeout time.Duration + Configure func(*PoolConfig) error + ConnectTimeout time.Duration + DSN string + HealthCheckPeriod time.Duration + MaxConnIdleTime time.Duration + MaxConnLifetime time.Duration + MaxConnLifetimeJitter time.Duration + MaxConns int32 + MinConns int32 + MinIdleConns int32 + Observer Observer + PingTimeout time.Duration + SessionInit func(context.Context, *pgx.Conn) error + ShutdownTimeout time.Duration + StartupPolicy StartupPolicy + TLS TLSConfig + type ConfigError struct + Cause error + Field string + Problem string + func (e *ConfigError) Error() string + func (e *ConfigError) Unwrap() error + type ErrorInfo struct + Cause error + Column string + Constraint string + Detail string + Hint string + Kind ErrorKind + Postgres *pgconn.PgError + Retryable bool + SQLState string + Schema string + Severity string + Table string + func Classify(err error) ErrorInfo + type ErrorKind string + const ErrorCancellation + const ErrorCheckViolation + const ErrorConnectivity + const ErrorDeadlock + const ErrorExclusionViolation + const ErrorForeignKeyViolation + const ErrorLockUnavailable + const ErrorNone + const ErrorPoolExhaustion + const ErrorQueryCanceled + const ErrorSerializationFailure + const ErrorTimeout + const ErrorUniqueViolation + const ErrorUnknown + type Health struct + Err error + Ready bool + Stats Stats + type Observation struct + Duration time.Duration + ErrorKind ErrorKind + HasPoolStats bool + Operation Operation + Outcome Outcome + Pool Stats + SQLState string + type Observer interface + Observe func(context.Context, Observation) + func NewSlogObserver(logger *slog.Logger) Observer + type ObserverFunc func(context.Context, Observation) + func (f ObserverFunc) Observe(ctx context.Context, observation Observation) + type Operation string + const OperationAcquire + const OperationClose + const OperationPing + const OperationSavepoint + const OperationTransaction + type Outcome string + const OutcomeError + const OutcomePanic + const OutcomeSuccess + type Pool struct + func New(ctx context.Context, input Config) (*Pool, error) + func (p *Pool) Acquire(ctx context.Context) (*pgxpool.Conn, error) + func (p *Pool) Close(ctx context.Context) error + func (p *Pool) Liveness() Health + func (p *Pool) Ping(ctx context.Context) error + func (p *Pool) Raw() *pgxpool.Pool + func (p *Pool) Readiness(ctx context.Context) Health + func (p *Pool) Stats() Stats + type PoolConfig = pgxpool.Config + func ParseConfig(input Config) (*PoolConfig, error) + type SavepointOptions struct + CleanupTimeout time.Duration + Observer Observer + type StartupPolicy uint8 + const StartupLazy + const StartupPing + type Stats struct + AcquireCount int64 + AcquiredConns int32 + CanceledAcquireCount int64 + ConstructingConns int32 + EmptyAcquireCount int64 + EmptyAcquireWaitTime time.Duration + IdleConns int32 + MaxConns int32 + NewConnsCount int64 + TotalConns int32 + type TLSConfig struct + Config *tls.Config + Mode TLSMode + type TLSMode uint8 + const TLSDisable + const TLSFromDSN + const TLSRequire + type TransactionOptions struct + CleanupTimeout time.Duration + Observer Observer