crdbpgx

package
v2.0.0-...-3201898 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

README

crdbpgxv5 is a wrapper around the logic for issuing SQL transactions which performs retries (as required by CockroachDB) when using github.com/jackc/pgx in standalone-library mode. crdbpgxv5 only supports pgx/v5.

Note: use crdbpgx for pgx/v4 support

If you're using pgx just as a driver for the standard database/sql package, use the parent crdb package instead.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecuteTx

func ExecuteTx(
	ctx context.Context, conn Conn, txOptions pgx.TxOptions, fn func(pgx.Tx) error,
) error

ExecuteTx runs fn inside a transaction and retries it as needed. On non-retryable failures, the transaction is aborted and rolled back; on success, the transaction is committed.

See crdb.ExecuteTx() for more information.

conn can be a pgx.Conn or a pgxpool.Pool.

Types

type Conn

type Conn interface {
	Begin(context.Context) (pgx.Tx, error)
	BeginTx(context.Context, pgx.TxOptions) (pgx.Tx, error)
}

Conn abstracts pgx transactions creators: pgx.Conn and pgxpool.Pool.

Jump to

Keyboard shortcuts

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