Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewTxnProvider ¶
func NewTxnProvider(pool *pgxpool.Pool) (TxnManager, ConnGetter)
Types ¶
type Conn ¶
type Conn interface {
Exec(ctx context.Context, sql string, arguments ...any) (pgconn.CommandTag, error)
Query(ctx context.Context, sql string, arguments ...any) (pgx.Rows, error)
QueryRow(ctx context.Context, sql string, arguments ...any) pgx.Row
}
Conn provides a common interface for executing queries across different pgx connection types.
type ConnGetter ¶
ConnGetter returns a Conn for the current context. If a transaction is in progress, it returns the transaction Conn, otherwise it returns the pool Conn.
type TxnBeginError ¶
type TxnBeginError struct {
Err error
}
func (TxnBeginError) Error ¶
func (e TxnBeginError) Error() string
func (TxnBeginError) Unwrap ¶
func (e TxnBeginError) Unwrap() error
type TxnCommitError ¶
type TxnCommitError struct {
Err error
}
func (TxnCommitError) Error ¶
func (e TxnCommitError) Error() string
func (TxnCommitError) Unwrap ¶
func (e TxnCommitError) Unwrap() error
type TxnManager ¶
type TxnManager interface {
RunInTxn(ctx context.Context, fn func(ctx context.Context) error, opts ...TxnOption) error
}
TxnManager provides a way to run multiple queries in a transaction.
type TxnOptions ¶
type TxnRollbackError ¶
func (TxnRollbackError) Error ¶
func (e TxnRollbackError) Error() string
func (TxnRollbackError) Unwrap ¶
func (e TxnRollbackError) Unwrap() error
Click to show internal directories.
Click to hide internal directories.