Documentation ¶
Index ¶
- Constants
- Variables
- func GetCurrentDBType() string
- func GetXaSqlTimeoutMs() int
- func MustGenGid(server string) string
- func SetCurrentDBType(dbType string)
- func SetXaSqlTimeoutMs(ms int)
- func TccGlobalTransaction(dtm string, gid string, tccFunc TccGlobalFunc) (rerr error)
- type BarrierBusiFunc
- type BranchBarrier
- type DB
- type Msg
- type Saga
- type Tcc
- type TccGlobalFunc
- type TransOptions
- type Xa
- type XaClient
- type XaGlobalFunc
- type XaLocalFunc
- type XaRegisterCallback
Constants ¶
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 ¶
var ErrFailure = dtmimp.ErrFailure
ErrFailure error for returned failure
var ErrOngoing = dtmimp.ErrOngoing
ErrOngoing error for returned ongoing
var MapFailure = dtmimp.MapFailure
MapFailure HTTP result of FAILURE
var MapSuccess = dtmimp.MapSuccess
MapSuccess HTTP result of SUCCESS
Functions ¶
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 ¶
BarrierBusiFunc type for busi func
type BranchBarrier ¶
BranchBarrier every branch info
func BarrierFrom ¶
func BarrierFrom(transType, gid, branchID, op string) (*BranchBarrier, error)
BarrierFrom construct transaction info from request
func BarrierFromQuery ¶
func BarrierFromQuery(qs url.Values) (*BranchBarrier, error)
BarrierFromQuery construct transaction info from request
func (*BranchBarrier) Call ¶
func (bb *BranchBarrier) Call(tx *sql.Tx, busiCall BarrierBusiFunc) (rerr error)
Call 子事务屏障,详细介绍见 https://zhuanlan.zhihu.com/p/388444465 tx: 本地数据库的事务对象,允许子事务屏障进行事务操作 busiCall: 业务函数,仅在必要时被调用
func (*BranchBarrier) CallWithDB ¶
func (bb *BranchBarrier) CallWithDB(db *sql.DB, busiCall BarrierBusiFunc) error
CallWithDB the same as Call, but with *sql.DB
func (*BranchBarrier) String ¶
func (bb *BranchBarrier) String() string
type Msg ¶
Msg reliable msg type
type Saga ¶
Saga struct of saga
func (*Saga) AddBranchOrder ¶
AddBranchOrder specify that branch should be after preBranches. branch should is larger than all the element in preBranches
func (*Saga) EnableConcurrent ¶
EnableConcurrent enable the concurrent exec of sub trans
type TccGlobalFunc ¶
TccGlobalFunc type of global tcc call
type Xa ¶
Xa xa transaction
func XaFromQuery ¶
XaFromQuery construct xa info from request
func (*Xa) CallBranch ¶
CallBranch call a xa branch
type XaClient ¶
type XaClient struct {
dtmimp.XaClientBase
}
XaClient xa client
func NewXaClient ¶
func NewXaClient(server string, mysqlConf map[string]string, notifyURL string, register XaRegisterCallback) (*XaClient, error)
NewXaClient construct a xa client
func (*XaClient) HandleCallback ¶
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 ¶
XaGlobalFunc type of xa global function
type XaLocalFunc ¶
XaLocalFunc type of xa local function
type XaRegisterCallback ¶
XaRegisterCallback type of xa register callback handler