storage

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

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 Storage

type Storage struct {
	// contains filtered or unexported fields
}

Storage is the data-access handle the composition root passes around.

func Open

func Open(ctx context.Context, dsn string) (*Storage, error)

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.

func WrapPool

func WrapPool(pool *pgxpool.Pool) *Storage

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.

func (*Storage) Close

func (s *Storage) Close()

Close releases the connection pool.

func (*Storage) Ping

func (s *Storage) Ping(ctx context.Context) error

Ping checks database connectivity.

func (*Storage) Pool

func (s *Storage) Pool() *pgxpool.Pool

Pool returns the underlying pgxpool. Composition-root use only — domain code reaches Postgres via its own typed Store packages.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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