7 Commits
Author SHA1 Message Date
Rene Nochebuena 8124c088d0 chore(db-sqlite): framework version alignment to v1.2.0 v1.2.0 2026-08-08 02:25:14 -06:00
Rene Nochebuena 2462570c90 chore(db-sqlite): framework version alignment to v1.1.3 v1.1.3 2026-08-08 01:26:49 -06:00
Rene Nochebuena 29d2d71ca9 chore(db-sqlite): framework version alignment to v1.1.2 v1.1.2 2026-08-08 00:43:43 -06:00
Rene Nochebuena 226e10630b docs(db-sqlite): fix wiring doc examples; align to v1.1.1 v1.1.1 2026-08-07 23:32:41 -06:00
Rene Nochebuena 585c76a525 docs(db-sqlite): fix fictional launcher.Register/health.Register in doc examples (#2)
The package-doc examples showed a fictional launcher.Register / health.Register
API (and launcher.Append as a package func). Corrected to the real wiring:
lc.Append + web/health.NewHandler(...).ServeHTTP.

Documentation-only. No code, API, or dependency changes; version stays v1.1.0
(the v1.1.0 tag is moved to include this fix). Verified by compiling the
corrected pattern against the real API.

Reviewed-on: #2
Co-authored-by: Rene Nochebuena Guerrero <rene@nochebuena.dev>
Co-committed-by: Rene Nochebuena Guerrero <rene@nochebuena.dev>
2026-08-07 22:20:14 -06:00
Rene Nochebuena 6a1fa2e697 chore(db-sqlite): 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-sqlite 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>
v1.1.0
2026-08-07 19:12:19 -06:00
Rene Nochebuena 0acf4da97e feat(db-sqlite): initial implementation — database/sql SQLite with lifecycle and UnitOfWork (v1.0.0)
Introduces code.nochebuena.dev/einherjar/db-sqlite — the SQLite database starter
for the Einherjar framework. Absorbs the sqlite package from micro-lib using the
pure-Go modernc.org/sqlite driver (no CGO, cross-compilation compatible).

Interfaces (CT-6: one TypeSpec per file):
- Executor — ExecContext, QueryContext, QueryRowContext (database/sql types)
- Tx — Executor + Commit(), Rollback() — no ctx; honest database/sql contract
- Provider — GetExecutor, Begin, Ping, HandleError
- Component — lifecycle.Component + observability.Checkable + Provider
- UnitOfWork — Do(ctx, fn)

Implementation:
- New(logger, cfg) Component — pool not created until OnInit
- OnInit: sql.Open with DSN (Path + Pragmas); sets MaxOpenConns, MaxIdleConns
- OnStart: Ping with 5s timeout; logs "sqlite: connected"
- OnStop: db.Close(); logs "sqlite: closing pool"
- GetExecutor: returns active Tx from context (ctxTxKey) or *sql.DB; explicit
  nil return when db uninitialized to avoid typed-nil interface pitfall
- Begin: wraps db.BeginTx; wrapped in xerrors on error
- HealthCheck: delegates to Ping; Priority LevelDegraded (file DB; absence
  is non-fatal on a server restart — file always present if configured)
- NewUnitOfWork(logger, provider) UnitOfWork — acquires writeMu before Begin
  to prevent SQLITE_BUSY under concurrent goroutines (SQLite single-writer model)
- writeMu: extracted from *sqliteImpl via type assertion in NewUnitOfWork;
  gracefully skipped when provider is a mock (nil mu)
- HandleError: sql.ErrNoRows→ErrNotFound, unique/pk constraint→ErrAlreadyExists,
  foreign key→ErrInvalidInput, all others→ErrInternal

Config (EINHERJAR_SQLITE_* env vars):
  Path(required), MaxOpenConns(1), MaxIdleConns(1),
  Pragmas(?_journal=WAL&_timeout=5000&_fk=true)

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