db

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 24, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package db owns the pgx connection pool and the goose migration runner. It embeds the migrations (via the migrations subpackage) and exposes a small WithTx transaction helper. It may import config only.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(ctx context.Context, dsn string, log *slog.Logger) (*pgxpool.Pool, error)

Connect opens a pgx pool and pings it. It retries the initial connection to tolerate compose start ordering (Postgres may not be ready the instant we boot).

func Migrate

func Migrate(ctx context.Context, dsn string) error

Migrate runs all embedded goose migrations up. It opens a short-lived database/sql handle over the pgx stdlib driver because goose needs one.

func WithTx

func WithTx(ctx context.Context, pool *pgxpool.Pool, fn func(pgx.Tx) error) error

WithTx runs fn inside a transaction, committing on nil error and rolling back otherwise. Services own their transaction boundaries through this helper.

Types

This section is empty.

Directories

Path Synopsis
Package migrations embeds the goose SQL migrations so they ship inside the binary and run on boot without a migrations directory on disk.
Package migrations embeds the goose SQL migrations so they ship inside the binary and run on boot without a migrations directory on disk.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL