crdbpgx

package
v2.2.3 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

README

crdbpgx 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. pgx versions below v4 are not supported.

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