Documentation
¶
Overview ¶
Package db wraps the Postgres pool, per-request user scoping and migrations.
Index ¶
- func Migrate(ctx context.Context, ownerURL string) error
- func MigrateTo(ctx context.Context, ownerURL, last string) error
- type DB
- func (d *DB) Close()
- func (d *DB) Listen(ctx context.Context, channel string, ready func(), ...) error
- func (d *DB) Ping(ctx context.Context) error
- func (d *DB) WithSystem(ctx context.Context, fn func(pgx.Tx) error) error
- func (d *DB) WithUser(ctx context.Context, userID string, fn func(pgx.Tx) error) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB is the application pool; it connects as braid_app (no BYPASSRLS).
func (*DB) Listen ¶
func (d *DB) Listen(ctx context.Context, channel string, ready func(), onNotify func(payload string)) error
Listen runs LISTEN on a dedicated connection and calls onNotify per notification; it reconnects with backoff (1 s..30 s) and returns nil once ctx is done. ready (may be nil) is called after every successful LISTEN.
func (*DB) WithSystem ¶
WithSystem runs fn in a transaction with no user; only definer functions return data.