transaction_manager

package module
v0.0.0-...-6d0321d Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2020 License: MIT Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

XormPlus-TransactionManager

xormplus transaction-manager is the xorm plus automatic transaction manager. With this library, you don’t need to worry about global transaction.

Installation

go get github.com/RuiFG/xormpuls-transactionmanager 

Simple Example

package main

import (
	"github.com/RuiFG/xormpuls-transactionmanager"
    _ "github.com/go-sql-driver/mysql"
	"github.com/xormplus/xorm"
)

type Test struct {
	id          int
	description string
}

func main() {
	db, _ := xorm.NewEngine("mysql", "root:123456@tcp(127.0.0.1:3306)/test?charset=utf8&parseTime=True&loc=Asia%2FShanghai")
	manager := transaction_manager.New(db)
	DynamicSession := manager.SessionFunc()
	test := Test{}
	_ = manager.Do(func(transaction *xorm.Transaction) error {
		return DynamicSession().Where("id = ?", 1).Find(&test)
	}, xorm.PROPAGATION_NEVER)
}

License

This project is under MIT License. See the LICENSE file for the full license text.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DynamicSession

type DynamicSession func() *Session

return the session of the transaction manager

type SessionStack

type SessionStack interface {
	Pop() (*Session, bool)
	Push(node *Session)
	Top() (*Session, bool)
	Size() int
	IsEmpty() bool
}

routine's session stack interface

func NewSessionStack

func NewSessionStack() SessionStack

type SynchronizeManager

type SynchronizeManager interface {
	Get() *Session
	Remove()
	Add(node *Session)
}

session synchronize manager interface

func NewSynchronizeManager

func NewSynchronizeManager(engineInterface EngineInterface) SynchronizeManager

type TransactionFunc

type TransactionFunc func(transaction *Transaction) error

transaction function

type TransactionManager

type TransactionManager interface {
	SessionFunc() DynamicSession
	Do(do TransactionFunc, transactionDefinition ...int) error
}

transaction manager interface

func New

func New(param EngineInterface) TransactionManager

Jump to

Keyboard shortcuts

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