12 Commits
Author SHA1 Message Date
Rene Nochebuena 9cabbe206b release: v1.7.1 (coordinated lockstep bump) 2026-08-18 18:44:30 -06:00
Rene Nochebuena d5ddfbcbe7 release: v1.7.0 (coordinated lockstep bump) 2026-08-18 17:56:33 -06:00
Rene Nochebuena 269e6c57fc release: v1.6.0 (coordinated lockstep bump) 2026-08-13 23:11:56 -06:00
Rene Nochebuena d1b73c5505 chore(db-postgres): framework version alignment to v1.5.0 2026-08-12 17:56:06 -06:00
Rene Nochebuena ffc0eb085b chore(db-postgres): dependency refresh; framework version alignment to v1.4.0 2026-08-12 15:28:45 -06:00
Rene Nochebuena 6b9794f683 chore(db-postgres): framework version alignment to v1.3.0 2026-08-08 10:48:40 -06:00
Rene Nochebuena 54f9c74562 chore(db-postgres): framework version alignment to v1.2.0 2026-08-08 02:25:07 -06:00
Rene Nochebuena 1bd1ab695c chore(db-postgres): framework version alignment to v1.1.3 2026-08-08 01:26:41 -06:00
Rene Nochebuena c333653655 chore(db-postgres): framework version alignment to v1.1.2 2026-08-08 00:43:35 -06:00
Rene Nochebuena 274bcce69f docs(db-postgres): fix wiring doc examples; align to v1.1.1 2026-08-07 23:32:34 -06:00
Rene Nochebuena fe3e0227d5 chore(db-postgres): bump einherjar deps to v1.1.0 (framework version alignment) (#1)
Patch of the coordinated framework release: einherjar modules move to v1.1.0
in lockstep, so db-postgres is bumped alongside the rest.

- go.mod: contracts, core -> v1.1.0 (via go get + go mod tidy)

No code or API changes. ModuleVersion() reports v1.1.0 automatically from
build info once tagged. Badge bumped to v1.1.0.

Reviewed-on: #1
Co-authored-by: Rene Nochebuena Guerrero <rene@nochebuena.dev>
Co-committed-by: Rene Nochebuena Guerrero <rene@nochebuena.dev>
2026-08-07 19:11:29 -06:00
Rene Nochebuena 4b58f8e3d9 feat(db-postgres): initial implementation — pgx pool with lifecycle and UnitOfWork (v1.0.0)
Introduces code.nochebuena.dev/einherjar/db-postgres — the PostgreSQL database
starter for the Einherjar framework. Absorbs the postgres package from micro-lib,
replacing fmt.Errorf wrapping with core/xerrors and migrating from pgx v4 to pgx v5.

Interfaces (CT-6: one TypeSpec per file):
- Executor — Exec, Query, QueryRow (pgx-native types)
- Tx — Executor + Commit(ctx), Rollback(ctx)
- Provider — GetExecutor, Begin, BeginTx, Ping, HandleError
- Component — lifecycle.Component + observability.Checkable + Provider + Stats()
- UnitOfWork — Do(ctx, fn)

Implementation:
- New(logger, cfg) Component — pool not created until OnInit
- OnInit: pgxpool.NewWithConfig with duration parsing; 30s timeout
- OnStart: PING with 5s timeout; logs "postgres: connected"
- OnStop: pool.Close(); logs "postgres: closing pool"
- GetExecutor: returns active Tx from context (ctxTxKey) or pool; nil-safe
- Begin/BeginTx: wraps pgx.TxOptions; wrapped in xerrors on error
- HealthCheck: delegates to Ping; Priority LevelCritical
- Stats() *pgxpool.Stat — zero value when pool uninitialized
- NewUnitOfWork(logger, provider) UnitOfWork — Begin+inject+commit/rollback
- HandleError: UniqueViolation→ErrAlreadyExists, ForeignKey/Check→ErrInvalidInput,
  pgx.ErrNoRows→ErrNotFound, all others→ErrInternal

Config (EINHERJAR_PG_* env vars):
  Host, Port(5432), User, Password, Name, SSLMode(disable), Timezone(UTC),
  MaxConns(5), MinConns(2), MaxConnLifetime(1h), MaxConnIdleTime(30m),
  HealthCheckPeriod(1m)

- Component interface embeds observability.Identifiable; identifiable.go implements
  ModulePath and ModuleVersion via runtime/debug.ReadBuildInfo() — prints in launcher banner
2026-05-29 15:50:20 +00:00