-
Release v1.0.0 Stable
released this
2026-05-11 19:37:43 -06:00 | 1 commits to main since this releasev1.0.0
code.nochebuena.dev/go/postgresOverview
postgresv1.0.0 commits the database client API as stable. All v0.9.0 roadmap items are
resolved. The module ships a pgx v5-native PostgreSQL client that integrates with thelauncher
lifecycle andhealthcheck systems, maps PostgreSQL errors to portablexerrorscodes, and
providesUnitOfWorkfor transactional repository patterns via context injection.What Changed Since v0.9.0
New in Client interface
BeginTx(ctx context.Context, opts pgx.TxOptions) (Tx, error)— starts a transaction with
explicit isolation level and read-only options using pgx-nativepgx.TxOptions.Begin(ctx)
is now a convenience wrapper callingBeginTx(ctx, pgx.TxOptions{}).tx, err := db.BeginTx(ctx, pgx.TxOptions{ IsoLevel: pgx.Serializable, AccessMode: pgx.ReadWrite, })New in Component interface
Stats() *pgxpool.Stat— exposes connection pool metrics for observability. Returns a
zero-value*pgxpool.Statwhen called beforeOnInit. Useful for Prometheus gauges or
health dashboards:stats := db.Stats() // stats.TotalConns(), stats.IdleConns(), stats.AcquiredConns(), stats.MaxConns()Dependency bumps
All micro-lib dependencies promoted to v1.0.0:
logz,health,launcher,xerrors.Roadmap items resolved
Item Resolution BeginTx(ctx, opts)for serialisable isolation✅ Added to Clientwithpgx.TxOptions;Beginrefactored as wrapperStats()for pool observability✅ Added Stats() *pgxpool.StattoComponentSELECT 1health check option❌ No — pgxpool.Pingalready acquires a real connection and does a round-trip; SELECT 1 adds no additional signalProduction feedback on pool defaults ✅ Validated as-is — MaxConns=5,MinConns=2,1h/30m/1mconfirmed in productionFull API (stable)
Executor—Exec,Query,QueryRowusing pgx v5 native types (pgconn.CommandTag,pgx.Rows,pgx.Row).Tx— extendsExecutorwithCommit(ctx) error,Rollback(ctx) error.Client—GetExecutor(ctx) Executor,Begin(ctx) (Tx, error),BeginTx(ctx, pgx.TxOptions) (Tx, error),Ping(ctx) error,HandleError(err) error.Component—launcher.Component+health.Checkable+Client+Stats() *pgxpool.Stat.UnitOfWork—Do(ctx, fn) error; injects activepgx.Txvia context.Config—Host,Port,User,Password,Name,SSLMode,Timezone,MaxConns,MinConns,MaxConnLifetime,MaxConnIdleTime,HealthCheckPeriod; env-tag support.New(logger logz.Logger, cfg Config) Component— constructor; pool created inOnInit.NewUnitOfWork(logger logz.Logger, client Client) UnitOfWork— wraps aClientfor transactionalDosemantics.HandleError(err error) error— maps pgx/PostgreSQL errors to xerrors:UniqueViolation→ErrAlreadyExists;ForeignKeyViolation/CheckViolation→ErrInvalidInput;pgx.ErrNoRows→ErrNotFound; others →ErrInternal.Migration from v0.9.0
BeginTxis a new method onClient. Any type that implementsClientmust now also
implementBeginTx. The existingBeginbehavior is unchanged.Statsis a new method onComponent. Any type that implementsComponentmust now also
implementStats.go get code.nochebuena.dev/go/postgres@v1.0.0Downloads