with

package
v0.0.0-...-fc9f681 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrRollback = errors.New("ErrRollback")

ErrRollback is used stop with.Tx

Functions

func Close

func Close(cl Closer, fn func())

Close is convenient wrapper for closing after performing some action

func Lock

func Lock(l Locker, fn func())

Lock simple wrapper for locking -> performing action -> unlocking

func Tx

func Tx(dbConn *sql.DB, fn TxFunc, opts ...*sql.TxOptions) error

Tx (with.Tx()) encapsulates common pattern of transaction

func TxContext

func TxContext(ctx context.Context, dbConn *sql.DB, fn TxFunc, opts ...*sql.TxOptions) (err error)

TxContext encapsulates common pattern of transaction

Types

type Closer

type Closer interface {
	Close() error
}

Closer interface with Close() error function

type Locker

type Locker interface {
	Lock()
	Unlock()
}

type TxFunc

type TxFunc func(tx *sql.Tx) error

TxFunc is func used to perform inside transaction

Jump to

Keyboard shortcuts

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