Documentation
¶
Overview ¶
Package storage owns the Postgres connection pool and runs migrations.
In the new arch the catalog "domain repos" that used to live here moved out: each `app/X.Store` constructs its own sqlc-backed queries via `gen.New(pool)` against the pool surfaced by Storage.Pool(). Storage's remaining job is composition-root plumbing — open, ping, hand out the pool, close.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PoolOption ¶ added in v0.9.3
type PoolOption func(*poolSettings)
PoolOption tunes the connection pool. A zero/negative value is ignored, so callers can pass config knobs directly and unset ones keep the defaults.
func WithMaxConns ¶ added in v0.9.3
func WithMaxConns(n int) PoolOption
WithMaxConns overrides the pool's maximum connections (ignored if n <= 0).
func WithMinConns ¶ added in v0.9.3
func WithMinConns(n int) PoolOption
WithMinConns overrides the pool's warm-floor connections (ignored if n <= 0). A higher floor keeps connections pre-established, so bursty load never pays cold-connection (dial + DNS) latency on the request path.
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
Storage is the data-access handle the composition root passes around.
func Open ¶
Open opens a connection pool, runs pending migrations, and returns a ready-to-use *Storage. The returned Storage must be closed with Close when no longer needed. Pool sizing defaults to MaxConns 10 / MinConns 2; pass WithMaxConns / WithMinConns to override.
func WrapPool ¶
WrapPool wraps an existing *pgxpool.Pool into a *Storage without opening a new pool or running migrations. Intended for tests that supply their own pool. The returned Storage must NOT be closed — the caller owns the pool's lifetime.