dbutil

package
v0.0.16 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2024 License: MPL-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithExecutorTx added in v0.0.13

func WithExecutorTx(ctx context.Context, exec riverdriver.Executor, innerFunc func(ctx context.Context, tx riverdriver.ExecutorTx) error) error

WithExecutorTx starts and commits a transaction on a driver executor around the given function, allowing the return of a generic value.

func WithExecutorTxV added in v0.0.13

func WithExecutorTxV[T any](ctx context.Context, exec riverdriver.Executor, innerFunc func(ctx context.Context, tx riverdriver.ExecutorTx) (T, error)) (T, error)

WithExecutorTxV starts and commits a transaction on a driver executor around the given function, allowing the return of a generic value.

func WithTx

func WithTx(ctx context.Context, txBeginner TxBeginner, innerFunc func(ctx context.Context, tx pgx.Tx) error) error

WithTx starts and commits a transaction around the given function, allowing the return of a generic value.

func WithTxV

func WithTxV[T any](ctx context.Context, txBeginner TxBeginner, innerFunc func(ctx context.Context, tx pgx.Tx) (T, error)) (T, error)

WithTxV starts and commits a transaction around the given function, allowing the return of a generic value.

Types

type Executor

type Executor interface {
	TxBeginner
	dbsqlc.DBTX
}

Executor is an interface for a type that can begin a transaction and also perform all the operations needed to be used in conjunction with sqlc. Implemented by all of pgx's `pgxpool.Pool`, `pgx.Conn`, and `pgx.Tx` (transactions can start subtransactions).

type TxBeginner

type TxBeginner interface {
	Begin(ctx context.Context) (pgx.Tx, error)
}

TxBeginner is an interface to a type that can begin a transaction, like a pgx connection pool, connection, or transaction (the latter would begin a subtransaction).

Jump to

Keyboard shortcuts

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