txs

package
v0.0.0-...-b9360c4 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2023 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoScope = errors.New("no transaction scope")
)

Functions

func Logger

func Logger(ctx context.Context) *zap.SugaredLogger

func RequireTransaction

func RequireTransaction(ctx context.Context, pool *pgxpool.Pool) (pgx.Tx, error)

Types

type Queryable

type Queryable interface {
	Exec(context.Context, string, ...any) (pgconn.CommandTag, error)
	Query(context.Context, string, ...any) (pgx.Rows, error)
	SendBatch(context.Context, *pgx.Batch) pgx.BatchResults
}

func RequireQueryable

func RequireQueryable(ctx context.Context, pool *pgxpool.Pool) (Queryable, error)

type TransactionScope

type TransactionScope struct {
	// contains filtered or unexported fields
}

func NewTransactionScope

func NewTransactionScope(ctx context.Context, db *pgxpool.Pool) (context.Context, *TransactionScope)

func ScopeIfAny

func ScopeIfAny(ctx context.Context) *TransactionScope

func (*TransactionScope) Commit

func (scope *TransactionScope) Commit(ctx context.Context) error

func (*TransactionScope) Rollback

func (scope *TransactionScope) Rollback(ctx context.Context) error

func (*TransactionScope) Tx

func (scope *TransactionScope) Tx(db *pgxpool.Pool) pgx.Tx

type TransactionScopeKey

type TransactionScopeKey string

Jump to

Keyboard shortcuts

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