dbtxn

package
v0.9.14 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2021 License: MIT Imports: 6 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
	Err   error
}

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) 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

func (*Context) SetError added in v0.9.10

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

SetError to set error to txn context

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