tx

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSerialization = errors.New("serialization error")
	ErrCommit        = errors.New("commit error")
	ErrBeginTx       = errors.New("begin tx error")
)
View Source
var ErrSerializationRepeatTimesExcedeed = errors.New("serialization repeat times exceeded")

Functions

func Exec

func Exec(
	tx CommitRollbacker,
	exec func() error,
) error

func Run

func Run(
	ctx context.Context,
	beginner Beginner,
	withTx func(txContext context.Context) error,
	opts ...Option,
) error

Types

type Beginner

type Beginner interface {
	Begin(ctx context.Context) (Tx, error)
	BeginTx(ctx context.Context, opts *sql.TxOptions) (Tx, error)
}

func BeginnerWithDriver

func BeginnerWithDriver(beginner Beginner, driver Driver) Beginner

type CommitRollbacker

type CommitRollbacker interface {
	Commit() error
	Rollback() error
}

func CommitRollbackerWithDriver

func CommitRollbackerWithDriver(tx CommitRollbacker, driver Driver) CommitRollbacker

type Driver

type Driver interface {
	Error(err error) error
}

type Option

type Option func(*options)

func RetrySerialization

func RetrySerialization(times int) Option

func TxOptions

func TxOptions(opts *sql.TxOptions) Option

type Tx

type Tx interface {
	Context() context.Context
	CommitRollbacker
}

func TxWithDriver

func TxWithDriver(tx Tx, driver Driver) Tx

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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