dtmcli

package
v1.7.2 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2021 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// StatusPrepared status for global/branch trans status.
	StatusPrepared = "prepared"
	// StatusSubmitted status for global trans status.
	StatusSubmitted = "submitted"
	// StatusSucceed status for global/branch trans status.
	StatusSucceed = "succeed"
	// StatusFailed status for global/branch trans status.
	StatusFailed = "failed"
	// StatusAborting status for global trans status.
	StatusAborting = "aborting"

	// BranchTry branch type for TCC
	BranchTry = "try"
	// BranchConfirm branch type for TCC
	BranchConfirm = "confirm"
	// BranchCancel branch type for TCC
	BranchCancel = "cancel"
	// BranchAction branch type for message, SAGA, XA
	BranchAction = "action"
	// BranchCompensate branch type for SAGA
	BranchCompensate = "compensate"
	// BranchCommit branch type for XA
	BranchCommit = "commit"
	// BranchRollback branch type for XA
	BranchRollback = "rollback"

	// ResultSuccess for result of a trans/trans branch
	ResultSuccess = dtmimp.ResultSuccess
	// ResultFailure for result of a trans/trans branch
	ResultFailure = dtmimp.ResultFailure
	// ResultOngoing for result of a trans/trans branch
	ResultOngoing = dtmimp.ResultOngoing

	// DBTypeMysql const for driver mysql
	DBTypeMysql = dtmimp.DBTypeMysql
	// DBTypePostgres const for driver postgres
	DBTypePostgres = dtmimp.DBTypePostgres
)

Variables

View Source
var ErrFailure = dtmimp.ErrFailure

ErrFailure error for returned failure

View Source
var ErrOngoing = dtmimp.ErrOngoing

ErrOngoing error for returned ongoing

View Source
var MapFailure = dtmimp.MapFailure

MapFailure HTTP result of FAILURE

View Source
var MapSuccess = dtmimp.MapSuccess

MapSuccess HTTP result of SUCCESS

Functions

func GetCurrentDBType added in v1.3.0

func GetCurrentDBType() string

GetCurrentDBType get currentDBType

func GetXaSqlTimeoutMs added in v1.6.0

func GetXaSqlTimeoutMs() int

GetXaSqlTimeoutMs get XaSqlTimeoutMs

func MustGenGid

func MustGenGid(server string) string

MustGenGid generate a new gid

func SetCurrentDBType added in v1.3.0

func SetCurrentDBType(dbType string)

SetCurrentDBType set currentDBType

func SetXaSqlTimeoutMs added in v1.6.4

func SetXaSqlTimeoutMs(ms int)

SetXaSqlTimeoutMs set XaSqlTimeoutMs

func TccGlobalTransaction

func TccGlobalTransaction(dtm string, gid string, tccFunc TccGlobalFunc) (rerr error)

TccGlobalTransaction begin a tcc global transaction dtm dtm服务器地址 gid 全局事务id tccFunc tcc事务函数,里面会定义全局事务的分支

Types

type BarrierBusiFunc added in v1.5.0

type BarrierBusiFunc func(tx *sql.Tx) error

BarrierBusiFunc type for busi func

type BranchBarrier added in v0.10.0

type BranchBarrier struct {
	TransType string
	Gid       string
	BranchID  string
	Op        string
	BarrierID int
}

BranchBarrier every branch info

func BarrierFrom added in v0.10.1

func BarrierFrom(transType, gid, branchID, op string) (*BranchBarrier, error)

BarrierFrom construct transaction info from request

func BarrierFromQuery added in v0.10.0

func BarrierFromQuery(qs url.Values) (*BranchBarrier, error)

BarrierFromQuery construct transaction info from request

func (*BranchBarrier) Call added in v0.10.0

func (bb *BranchBarrier) Call(tx *sql.Tx, busiCall BarrierBusiFunc) (rerr error)

Call 子事务屏障,详细介绍见 https://zhuanlan.zhihu.com/p/388444465 tx: 本地数据库的事务对象,允许子事务屏障进行事务操作 busiCall: 业务函数,仅在必要时被调用

func (*BranchBarrier) CallWithDB added in v1.6.2

func (bb *BranchBarrier) CallWithDB(db *sql.DB, busiCall BarrierBusiFunc) error

CallWithDB the same as Call, but with *sql.DB

func (*BranchBarrier) String added in v0.10.0

func (bb *BranchBarrier) String() string

type DB added in v0.10.3

type DB = dtmimp.DB

DB interface

type DBConf added in v1.7.0

type DBConf = dtmimp.DBConf

type Msg

type Msg struct {
	dtmimp.TransBase
}

Msg reliable msg type

func NewMsg

func NewMsg(server string, gid string) *Msg

NewMsg create new msg

func (*Msg) Add

func (s *Msg) Add(action string, postData interface{}) *Msg

Add add a new step

func (*Msg) Prepare

func (s *Msg) Prepare(queryPrepared string) error

Prepare prepare the msg, msg will later be submitted

func (*Msg) Submit

func (s *Msg) Submit() error

Submit submit the msg

type Saga

type Saga struct {
	dtmimp.TransBase
	// contains filtered or unexported fields
}

Saga struct of saga

func NewSaga

func NewSaga(server string, gid string) *Saga

NewSaga create a saga

func (*Saga) Add

func (s *Saga) Add(action string, compensate string, postData interface{}) *Saga

Add add a saga step

func (*Saga) AddBranchOrder added in v1.4.1

func (s *Saga) AddBranchOrder(branch int, preBranches []int) *Saga

AddBranchOrder specify that branch should be after preBranches. branch should is larger than all the element in preBranches

func (*Saga) EnableConcurrent added in v1.4.0

func (s *Saga) EnableConcurrent() *Saga

EnableConcurrent enable the concurrent exec of sub trans

func (*Saga) Submit

func (s *Saga) Submit() error

Submit submit the saga trans

type Tcc

type Tcc struct {
	dtmimp.TransBase
}

Tcc struct of tcc

func TccFromQuery added in v0.10.0

func TccFromQuery(qs url.Values) (*Tcc, error)

TccFromQuery tcc from request info

func (*Tcc) CallBranch

func (t *Tcc) CallBranch(body interface{}, tryURL string, confirmURL string, cancelURL string) (*resty.Response, error)

CallBranch call a tcc branch

type TccGlobalFunc

type TccGlobalFunc func(tcc *Tcc) (*resty.Response, error)

TccGlobalFunc type of global tcc call

type TransOptions added in v1.4.0

type TransOptions = dtmimp.TransOptions

TransOptions transaction option

type Xa

type Xa struct {
	dtmimp.TransBase
}

Xa xa transaction

func XaFromQuery added in v0.10.0

func XaFromQuery(qs url.Values) (*Xa, error)

XaFromQuery construct xa info from request

func (*Xa) CallBranch

func (x *Xa) CallBranch(body interface{}, url string) (*resty.Response, error)

CallBranch call a xa branch

type XaClient

type XaClient struct {
	dtmimp.XaClientBase
}

XaClient xa client

func NewXaClient

func NewXaClient(server string, mysqlConf DBConf, notifyURL string, register XaRegisterCallback) (*XaClient, error)

NewXaClient construct a xa client

func (*XaClient) HandleCallback added in v0.10.0

func (xc *XaClient) HandleCallback(gid string, branchID string, action string) (interface{}, error)

HandleCallback 处理commit/rollback的回调

func (*XaClient) XaGlobalTransaction

func (xc *XaClient) XaGlobalTransaction(gid string, xaFunc XaGlobalFunc) (rerr error)

XaGlobalTransaction start a xa global transaction

func (*XaClient) XaLocalTransaction

func (xc *XaClient) XaLocalTransaction(qs url.Values, xaFunc XaLocalFunc) error

XaLocalTransaction start a xa local transaction

type XaGlobalFunc

type XaGlobalFunc func(xa *Xa) (*resty.Response, error)

XaGlobalFunc type of xa global function

type XaLocalFunc

type XaLocalFunc func(db *sql.DB, xa *Xa) error

XaLocalFunc type of xa local function

type XaRegisterCallback added in v0.10.0

type XaRegisterCallback func(path string, xa *XaClient)

XaRegisterCallback type of xa register callback handler

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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