• v1.0.0 bc99d76944

    Rene Nochebuena released this 2026-05-11 19:44:39 -06:00 | 1 commits to main since this release

    v1.0.0

    code.nochebuena.dev/go/sqlite

    Overview

    sqlite v1.0.0 commits the database client API as stable. All v0.9.0 roadmap items are
    validated in production. The module ships a pure-Go, CGO-free SQLite client backed by
    modernc.org/sqlite that integrates with the launcher lifecycle and health check systems,
    serialises write transactions through a mutex to prevent SQLITE_BUSY errors, and provides
    UnitOfWork for transactional repository patterns via context injection.

    What Changed Since v0.9.0

    No API changes. All micro-lib dependencies bumped from v0.9.0 to v1.0.0.

    Roadmap items resolved

    Item Resolution
    Read-only bypass for write mutex No — reads via GetExecutor already bypass writeMu; they go directly to *sql.DB concurrently. A separate read handle would complicate the API without meaningful benefit for embedded workloads
    WAL reader/writer pool separation No — requires two *sql.DB handles and a routing layer; out of scope for single-process embedded use case
    Pragmas as structured type No — raw DSN string is more flexible and the defaults are well-documented; a struct adds complexity for marginal benefit
    Production feedback on write-mutex approach Validated — WAL + writeMu serialisation confirmed stable under real workloads; no SQLITE_BUSY incidents

    Full API (stable)

    ExecutorExecContext, QueryContext, QueryRowContext using database/sql native types.

    Tx — extends Executor with Commit() error, Rollback() error (no context — honest database/sql contract).

    ClientGetExecutor(ctx) Executor, Begin(ctx) (Tx, error), Ping(ctx) error, HandleError(err) error.

    Componentlauncher.Component + health.Checkable + Client.

    UnitOfWorkDo(ctx, fn) error; acquires writeMu and injects active *sql.Tx via context.

    ConfigPath, MaxOpenConns, MaxIdleConns, Pragmas; env-tag support. Default Pragmas: ?_journal=WAL&_timeout=5000&_fk=true.

    New(logger logz.Logger, cfg Config) Component — constructor; database opened in OnInit.

    NewUnitOfWork(logger logz.Logger, client Client) UnitOfWork — wraps a Client for serialised transactional Do semantics.

    HandleError(err error) error — maps SQLite extended error codes to xerrors: 2067/1555 (unique/primary-key) → ErrAlreadyExists; 787 (foreign key) → ErrInvalidInput; sql.ErrNoRowsErrNotFound; others → ErrInternal.

    Migration from v0.9.0

    No breaking changes. Only the micro-lib indirect dependency versions change.

    go get code.nochebuena.dev/go/sqlite@v1.0.0
    
    Downloads