txpostgres

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsPgError

func AsPgError(err error) (*pgconn.PgError, bool)

func IsNoRows

func IsNoRows(err error) bool

func New

Types

type DBer

type DBer interface {
	Exec(ctx context.Context, sql string, args ...any) (ports.DatabaseResult, error)
	Query(ctx context.Context, sql string, args ...any) (ports.DatabaseRows, error)
	QueryRow(ctx context.Context, sql string, args ...any) ports.DatabaseRow
}

DBer is satisfied by transactions and the pool facade below.

func FromCtx

func FromCtx(ctx context.Context, pool ports.DatabasePool) DBer

FromCtx returns the active transaction if present; otherwise a facade that acquires/releases a connection per call (no leaks).

type Manager

type Manager struct {
	Pool ports.DatabasePool
}

Manager implements ports.TxManager using a pgx-like pool.

func (*Manager) WithinTx

func (m *Manager) WithinTx(
	ctx context.Context, fn func(ctx context.Context) error,
) error

Jump to

Keyboard shortcuts

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