• v1.0.0 f43fc8056c

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

    v1.0.0

    code.nochebuena.dev/go/mysql

    Overview

    mysql v1.0.0 commits the database client API as stable. All v0.9.x roadmap items are
    resolved. The module ships a database/sql-backed MySQL client that integrates with the
    launcher lifecycle and health check systems, maps driver errors to portable xerrors
    codes, and provides UnitOfWork for transactional repository patterns via context injection.

    What Changed Since v0.9.1

    New in Client interface

    BeginTx(ctx context.Context, opts *sql.TxOptions) (Tx, error) — starts a transaction with
    explicit isolation level and read-only options. Begin(ctx) is now a convenience wrapper
    calling BeginTx(ctx, nil).

    tx, err := db.BeginTx(ctx, &sql.TxOptions{
        Isolation: sql.LevelSerializable,
        ReadOnly:  false,
    })
    

    New in Component interface

    Stats() sql.DBStats — exposes connection pool metrics for observability. Returns
    sql.DBStats{} (zero value) when called before OnInit. Useful for Prometheus gauges or
    health dashboards:

    stats := db.Stats()
    // stats.OpenConnections, stats.WaitCount, stats.WaitDuration, ...
    

    Dependency bumps

    All micro-lib dependencies promoted to v1.0.0: logz, health, launcher, xerrors.

    Roadmap items resolved

    Item Resolution
    BeginTx(ctx, opts) for isolation levels Added to Client; Begin refactored as wrapper
    Stats() sql.DBStats for pool observability Added to Component
    DSN params (parseTime, loc, charset) in Config Done in v0.9.1 — Charset, Loc, ParseTime fields with backward-compatible defaults
    Production feedback on pool defaults Validated as-is — MaxConns=5, MinConns=2, 1h/30m confirmed in production

    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), BeginTx(ctx, opts) (Tx, error), Ping(ctx) error, HandleError(err) error.

    Componentlauncher.Component + health.Checkable + Client + Stats() sql.DBStats.

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

    ConfigHost, Port, User, Password, Name, MaxConns, MinConns, MaxConnLifetime, MaxConnIdleTime, Charset, Loc, ParseTime; env-tag support.

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

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

    HandleError(err error) error — maps MySQL driver errors to xerrors: 1062ErrAlreadyExists; 1216/1217/1451/1452ErrInvalidInput; sql.ErrNoRowsErrNotFound; others → ErrInternal.

    Migration from v0.9.1

    BeginTx is a new method on Client. Any type that implements Client must now also
    implement BeginTx. The existing Begin behavior is unchanged.

    Stats is a new method on Component. Any type that implements Component must now also
    implement Stats.

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