trans

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2020 License: MIT Imports: 3 Imported by: 2

Documentation

Overview

Package trans gorm 事务封装

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecTrans

func ExecTrans(ctx context.Context, db *gorm.DB, f Func) error

ExecTrans 执行事务

func ExecTransWithLock

func ExecTransWithLock(ctx context.Context, db *gorm.DB, cb Func) error

ExecTransWithLock 执行事务(加锁)

func FromTransCtx added in v0.3.0

func FromTransCtx(ctx context.Context) interface{}

FromTransCtx 从上下文中获取事务

func FromTransLockCtx added in v0.3.0

func FromTransLockCtx(ctx context.Context) bool

FromTransLockCtx 从上下文中获取事务锁

func NewTransCtx added in v0.3.0

func NewTransCtx(ctx context.Context, trans interface{}) context.Context

NewTransCtx 创建事务的上下文

func NewTransLockCtx added in v0.3.0

func NewTransLockCtx(ctx context.Context) context.Context

NewTransLockCtx 创建事务锁的上下文

Types

type Func added in v0.2.7

type Func func(context.Context) error

Func 定义事务执行函数

type Trans

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

Trans 事务管理

func New added in v0.2.7

func New(db *gorm.DB) *Trans

New 创建事务管理实例

func (*Trans) Begin

func (a *Trans) Begin() (interface{}, error)

Begin 开启事务,返回事务句柄

func (*Trans) Commit

func (a *Trans) Commit(trans interface{}) error

Commit 提交事务

func (*Trans) Rollback

func (a *Trans) Rollback(trans interface{}) error

Rollback 回滚事务

Jump to

Keyboard shortcuts

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