Documentation
¶
Index ¶
- func OpenPool(ctx context.Context, cfg DBConnConfig, mp otelmetric.MeterProvider, ...) (*pgxpool.Pool, error)
- func Query[T any](ctx context.Context, tx Querier, query string, ...) ([]T, error)
- func RunMigrations(ctx context.Context, log *slog.Logger, cfg DBConnConfig, name string, ...) error
- type DBConnConfig
- type PoolOption
- type Querier
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func OpenPool ¶
func OpenPool(ctx context.Context, cfg DBConnConfig, mp otelmetric.MeterProvider, tp oteltrace.TracerProvider, name string, opts ...PoolOption) (*pgxpool.Pool, error)
OpenPool opens a pgxpool.Pool from cfg with otelpgx tracing and stats wiring. name is applied as a `pool` attribute to all stats metrics so multiple pools pointing at the same host:port/database can be distinguished in metrics backends. opts may override fields on the parsed pgxpool.Config (e.g. MaxConns/MinConns).
func RunMigrations ¶
func RunMigrations(ctx context.Context, log *slog.Logger, cfg DBConnConfig, name string, migrationsFS fs.FS) error
RunMigrations applies pending migrations from migrationsFS using goose. The DSN must bypass PgBouncer because goose relies on session-level pg_advisory_lock for cross-replica coordination. name scopes goose's tracking table and advisory lock so multiple modules can share the same database without colliding.
Types ¶
type DBConnConfig ¶
DBConnConfig is the configuration for opening a single pool or running migrations.
type PoolOption ¶
PoolOption overrides fields on the pgxpool.Config parsed from the DSN before the pool is opened.
func WithMaxConns ¶
func WithMaxConns(n int32) PoolOption
WithMaxConns overrides the pool's MaxConns.
func WithMinConns ¶
func WithMinConns(n int32) PoolOption
WithMinConns overrides the pool's MinConns.