- Remove //go:build red_gate tag from internal/web/handlers_test.go and internal/db/pool_test.go now that consumer symbols are about to exist - go mod tidy after real importers land (deferred from Plan 01-01 per Codex concern #1) — chi/v5, templ, pgx/v5, google/uuid now in require list - internal/db/pool.go: NewPool(ctx, dsn) builds a pgxpool.Pool with MaxConns=10, MinConns=1; no eager Ping (RESEARCH Pitfall 2) - internal/web/slog.go: NewSlogHandler returns JSON when env='production', text otherwise; pure helper, no slog.SetDefault side effect - internal/web/middleware.go: RequestIDMiddleware (UUIDv4 → ctx + X-Request-ID header), LoggerFromContext helper, SlogLoggerMiddleware factory using chi WrapResponseWriter; field allowlist per V7/T-01-09
23 lines
710 B
Go
23 lines
710 B
Go
// Package db owns the Postgres connection pool wiring and (in later phases)
|
|
// sqlc-generated query methods.
|
|
package db
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/jackc/pgx/v5/pgxpool"
|
|
)
|
|
|
|
// NewPool constructs a *pgxpool.Pool from the supplied DSN. Connections are
|
|
// lazy — NewPool does NOT call Ping (RESEARCH Pitfall 2: lazy is the
|
|
// canonical pgxpool behavior; callers exercise the pool via /healthz instead
|
|
// of an eager startup ping). Returns an error if the DSN cannot be parsed.
|
|
func NewPool(ctx context.Context, dsn string) (*pgxpool.Pool, error) {
|
|
cfg, err := pgxpool.ParseConfig(dsn)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
cfg.MaxConns = 10
|
|
cfg.MinConns = 1
|
|
return pgxpool.NewWithConfig(ctx, cfg)
|
|
}
|