txn_pgx

package module
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PgxExecute

func PgxExecute[D txn.Doer[PgxOptions, PgxBeginner]](
	ctx context.Context, db PgxBeginner, do D, fn txn.DoFunc[PgxOptions, PgxBeginner, D]) (D, error)

PgxExecute executes a pgx transaction.

func PgxPing added in v0.0.6

func PgxPing[T any](
	ctx context.Context, beginner PgxBeginner, doer PgxDoer[T], sleep func(time.Duration, int)) (int, error)

PgxPing performs a ping operation.

Types

type PgxBeginner

type PgxBeginner = *pgxpool.Pool

PgxBeginner is an alias for *pgxpool.Pool.

type PgxDoer added in v0.0.4

type PgxDoer[Stmt any] interface {
	txn.Doer[PgxOptions, PgxBeginner]
	Stmt() Stmt
	SetStmt(Stmt)
}

PgxDoer defines the interface for PGX transaction operations.

type PgxDoerBase

type PgxDoerBase[Stmt any] struct {
	txn.DoerBase[PgxOptions, PgxBeginner]
	// contains filtered or unexported fields
}

PgxDoerBase provides a base implementation for the PgxDoer interface.

func (*PgxDoerBase[_]) IsReadOnly

func (do *PgxDoerBase[_]) IsReadOnly() bool

IsReadOnly checks if the transaction is read-only.

func (*PgxDoerBase[_]) SetReadOnly added in v0.0.5

func (do *PgxDoerBase[_]) SetReadOnly(title string)

SetReadOnly sets the transaction to read-only mode.

func (*PgxDoerBase[_]) SetReadWrite added in v0.0.5

func (do *PgxDoerBase[_]) SetReadWrite(title string)

SetReadWrite sets the transaction to read-write mode.

func (*PgxDoerBase[S]) SetStmt added in v0.0.3

func (do *PgxDoerBase[S]) SetStmt(s S)

SetStmt sets the statement.

func (*PgxDoerBase[S]) Stmt added in v0.0.3

func (do *PgxDoerBase[S]) Stmt() S

Stmt returns the statement.

type PgxOptions

type PgxOptions = *pgx.TxOptions

PgxOptions is an alias for *pgx.TxOptions.

type PgxTxn

type PgxTxn struct {
	Raw pgx.Tx
}

PgxTxn wraps a raw pgx.Tx transaction.

func PgxBeginTxn

func PgxBeginTxn(ctx context.Context, db PgxBeginner, opt PgxOptions) (*PgxTxn, error)

PgxBeginTxn begins a pgx transaction.

func (*PgxTxn) Commit

func (w *PgxTxn) Commit(ctx context.Context) error

Commit commits the transaction.

func (*PgxTxn) IsNil

func (w *PgxTxn) IsNil() bool

IsNil checks if the transaction is nil.

func (*PgxTxn) Rollback

func (w *PgxTxn) Rollback(ctx context.Context) error

Rollback rolls back the transaction.

Jump to

Keyboard shortcuts

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