transaction

package
v0.0.0-pre.4 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Begin

func Begin(ctx context.Context) (context.Context, transaction)

func Do

func Do(ctx context.Context, f func(ctx context.Context) error) (err error)

func Enable

func Enable(db db) dbtx

func ForceTx

func ForceTx(ctx context.Context, db DBTX, f func(context.Context, TX) error) (err error)

ForceTx operates like Do, but instead of waiting for the first db call to open a transaction, one is opened immediately and passed to the function argument.

Types

type DBTX

type DBTX interface {
	ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
	PrepareContext(ctx context.Context, query string) (*sql.Stmt, error)
	QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
	QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row
}

func GetDBTX

func GetDBTX(ctx context.Context, db DBTX) DBTX

GetDBTX returns the underlying TX if one exists in the context, otherwise returning the supplied DB.

type TX

type TX interface {
	DBTX
	// contains filtered or unexported methods
}

Jump to

Keyboard shortcuts

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