dbtxn

package
v0.9.21 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const ContextKey key = iota

ContextKey to get transaction

Variables

This section is empty.

Functions

func Error

func Error(ctx context.Context) error

Error of transaction

Types

type CommitFn

type CommitFn func() error

CommitFn is commit function to close the transaction

type Context

type Context struct {
	TxMap map[*sql.DB]Tx
	Errs  errkit.Errors
}

Context of transaction

func Begin

func Begin(parent *context.Context) *Context

Begin transaction

func Find added in v0.9.1

func Find(ctx context.Context) *Context

Find transaction context

func NewContext added in v0.9.11

func NewContext() *Context

NewContext return new instance of Context

func (*Context) AppendError added in v0.9.19

func (c *Context) AppendError(err error) bool

AppendError to append error to txn context

func (*Context) Begin added in v0.9.11

func (c *Context) Begin(ctx context.Context, db *sql.DB) (sq.StdSqlCtx, error)

Begin transaction

func (*Context) Commit

func (c *Context) Commit() error

Commit if no error

type Tx

type Tx interface {
	sq.StdSqlCtx
	Rollback() error
	Commit() error
}

Tx is interface for *db.Tx

type UseHandler added in v0.9.10

type UseHandler struct {
	*Context
	sq.StdSqlCtx
}

UseHandler responsible to handle transaction

func Use

func Use(ctx context.Context, db *sql.DB) (*UseHandler, error)

Use transaction if possible

Jump to

Keyboard shortcuts

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