sqlxtx

package
v0.0.0-...-b1203ac Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2023 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrIsTransaction     = errors.New("sqltx: underlying type is transaction")
	ErrNestedTransaction = errors.New("sqltx: transactions cannot be nested")
	ErrNonTransaction    = errors.New("sqltx: underlying type is not a transaction")
)
View Source
var ErrContextNotFound = errors.New("sqltx: Atomic not found in context")

Functions

func IsTx

func IsTx(ctx context.Context) bool

func IsolationLevel

func IsolationLevel(ctx context.Context, isoLevel sql.IsolationLevel) context.Context

func ReadOnly

func ReadOnly(ctx context.Context, readOnly bool) context.Context

func RunInTx

func RunInTx(ctx context.Context, db *sqlx.DB, opt *sql.TxOptions, fn func(tx *sqlx.Tx) error) (err error)

func TxOptions

func TxOptions(ctx context.Context) *sql.TxOptions

func WithValue

func WithValue(ctx context.Context, atm *Atomic) context.Context

Types

type Atomic

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

func MustValue

func MustValue(ctx context.Context) *Atomic

func New

func New(db *sqlx.DB, opts ...Option) *Atomic

func NewTx

func NewTx(tx *sqlx.Tx, opts ...Option) *Atomic

NewTx returns a Atomic with transaction.

func Value

func Value(ctx context.Context) (*Atomic, bool)

func (*Atomic) DB

func (a *Atomic) DB(ctx context.Context) DBTX

func (*Atomic) DBTx

func (a *Atomic) DBTx(ctx context.Context) DBTX

func (*Atomic) IsTx

func (a *Atomic) IsTx() bool

IsTx returns true if the underlying type is a transaction.

func (*Atomic) RunInTx

func (a *Atomic) RunInTx(ctx context.Context, fn func(context.Context) error) (err error)

func (*Atomic) Tx

func (a *Atomic) Tx(ctx context.Context) DBTX

type DBTX

type DBTX = sqlx.ExtContext

DBTX represents the common db operations for both *sql.DB and *sql.Tx.

type Middleware

type Middleware func(DBTX) DBTX

type Option

type Option interface {
	// contains filtered or unexported methods
}

Jump to

Keyboard shortcuts

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