Rene Nochebuena f43fc8056c feat(mysql)!: promote to v1.0.0 — BeginTx with isolation levels, Stats, bump all deps to v1.0.0
Add BeginTx(ctx, *sql.TxOptions) to Client interface for explicit transaction isolation
level control; Begin refactored as a convenience wrapper calling BeginTx(ctx, nil).
Add Stats() sql.DBStats to Component interface for connection pool observability.
Bump all micro-lib dependencies (logz, health, launcher, xerrors) from v0.9.0 to v1.0.0.
API committed as stable.
2026-05-12 01:20:35 +00:00

mysql

database/sql-backed MySQL client with launcher lifecycle and health check integration.

Install

go get code.nochebuena.dev/go/mysql

Usage

db := mysql.New(logger, cfg)
lc.Append(db)
r.Get("/health", health.NewHandler(logger, db))

Unit of Work

uow := mysql.NewUnitOfWork(logger, db)

err := uow.Do(ctx, func(ctx context.Context) error {
    exec := db.GetExecutor(ctx) // returns the active Tx
    _, err := exec.ExecContext(ctx, "INSERT INTO orders ...")
    return err
})

Error mapping

if err := db.HandleError(err); err != nil { ... }
MySQL error xerrors code
1062 (ER_DUP_ENTRY) ErrAlreadyExists
1216/1217/1451/1452 (foreign key) ErrInvalidInput
sql.ErrNoRows ErrNotFound
anything else ErrInternal

Configuration

Env var Default Description
MYSQL_HOST required Database host
MYSQL_PORT 3306 Database port
MYSQL_USER required Username
MYSQL_PASSWORD required Password
MYSQL_NAME required Database name
MYSQL_MAX_CONNS 5 Max open connections
MYSQL_MIN_CONNS 2 Max idle connections
Description
MySQL client with health check and lifecycle hooks.
Readme MIT 68 KiB
2026-05-11 19:21:56 -06:00
Languages
Go 100%