Versions in this module Expand all Collapse all v1 v1.1.0 Jul 10, 2026 v1.0.0 Jul 6, 2026 Changes in this version + var ErrNoTenantContext = errors.New("database: no tenant in context (WithTenant requires database.WithTenantID)") + var ErrVersionConflict = errors.New("database: version conflict") + func ActorIDFrom(ctx context.Context) (uuid.UUID, bool) + func AssertRLSEnforced(ctx context.Context, pool *pgxpool.Pool) error + func ExpectOneRow(tag pgconn.CommandTag, entity string) error + func MigrateReset(ctx context.Context, pool *pgxpool.Pool, src fs.FS, source string) (int64, error) + func NewPool(ctx context.Context, dsn string, cfg config.DB, opts ...Option) (*pgxpool.Pool, error) + func TenantIDFrom(ctx context.Context) (uuid.UUID, bool) + func WithActorID(ctx context.Context, id uuid.UUID) context.Context + func WithTenantID(ctx context.Context, id uuid.UUID) context.Context + type DB interface + type DBTX interface + Exec func(ctx context.Context, sql string, args ...any) (pgconn.CommandTag, error) + Query func(ctx context.Context, sql string, args ...any) (pgx.Rows, error) + QueryRow func(ctx context.Context, sql string, args ...any) pgx.Row + type IdemStore interface + Begin func(ctx context.Context, db TenantDB, actorScope, key, requestHash string, ...) (Replay, error) + Complete func(ctx context.Context, db TenantDB, actorScope, key string, status int, ...) error + Discard func(ctx context.Context, db TenantDB, actorScope, key string) error + type Manager struct + func NewManager(pool *pgxpool.Pool, cfg config.DB, opts ...ManagerOption) *Manager + func (m *Manager) Platform(ctx context.Context, fn func(ctx context.Context, db DB) error) error + func (m *Manager) WithTenant(ctx context.Context, fn func(ctx context.Context, db TenantDB) error) error + func (m *Manager) WithTenantRO(ctx context.Context, fn func(ctx context.Context, db TenantDB) error) error + type ManagerOption func(*Manager) + func WithRLSGuard() ManagerOption + func WithRole(role string) ManagerOption + type MigrateResult struct + Applied int + Version int64 + func Migrate(ctx context.Context, pool *pgxpool.Pool, src fs.FS, source string) (MigrateResult, error) + type Option func(*pgxpool.Config) + func WithConnRLSGuard() Option + func WithSetRole(role string) Option + type PgIdemStore struct + func NewIdemStore() *PgIdemStore + func NewIdemStoreWithClock(now func() time.Time) *PgIdemStore + func (s *PgIdemStore) Begin(ctx context.Context, db TenantDB, actorScope, key, requestHash string, ...) (Replay, error) + func (s *PgIdemStore) Complete(ctx context.Context, db TenantDB, actorScope, key string, status int, ...) error + func (s *PgIdemStore) Discard(ctx context.Context, db TenantDB, actorScope, key string) error + func (s *PgIdemStore) SweepExpired(ctx context.Context, plat TxManager, before time.Time) (int64, error) + type Replay struct + Found bool + Fresh bool + ResponseBody []byte + ResponseStatus int + type TenantDB interface + type TxManager interface + Platform func(ctx context.Context, fn func(ctx context.Context, db DB) error) error + WithTenant func(ctx context.Context, fn func(ctx context.Context, db TenantDB) error) error + WithTenantRO func(ctx context.Context, fn func(ctx context.Context, db TenantDB) error) error