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 DBConf
- 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 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 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
BarrierBusiFunc type for busi func
type BranchBarrier ¶ added in v0.10.0
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 Msg ¶
Msg reliable msg type
type Saga ¶
Saga struct of saga
func (*Saga) AddBranchOrder ¶ added in v1.4.1
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
EnableConcurrent enable the concurrent exec of sub trans
type Tcc ¶
Tcc struct of tcc
func TccFromQuery ¶ added in v0.10.0
TccFromQuery tcc from request info
type TccGlobalFunc ¶
TccGlobalFunc type of global tcc call
type TransOptions ¶ added in v1.4.0
type TransOptions = dtmimp.TransOptions
TransOptions transaction option
type Xa ¶
Xa xa transaction
func XaFromQuery ¶ added in v0.10.0
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 DBConf, notifyURL string, register XaRegisterCallback) (*XaClient, error)
NewXaClient construct a xa client
func (*XaClient) HandleCallback ¶ added in v0.10.0
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 ¶ added in v0.10.0
XaRegisterCallback type of xa register callback handler