transact

package
v0.0.0-...-b8f6862 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2020 License: Apache-2.0 Imports: 10 Imported by: 15

Documentation

Overview

config

transcommskeleton

distributed transcation coordinater

transctx

transhandler

transnode

transtype

Index

Constants

View Source
const (
	///transact execute result
	TransResult_Success int = iota
	TransResult_Failed
	TransResult_TimeOut
	TransResult_Max
)
View Source
const (
	///transact
	TransRootNodeLevel     int           = 0
	DefaultTransactTimeout time.Duration = 30 * time.Second
)
View Source
const (
	TransStatsOp_Exe = iota
	TransStatsOp_Rollback
	TransStatsOp_Commit
	TransStatsOp_Yiled
	TransStatsOp_Resume
	TransStatsOp_Timeout
)

Variables

View Source
var Config = Configuration{}
View Source
var (
	DTCModule = &transactCoordinater{transPool: make(map[TransNodeID]*TransNode)}
)
View Source
var (
	TransNodeIDNil = TransNodeID(0)
)

Functions

func ProcessTransCmd

func ProcessTransCmd(tid TransNodeID, cmd TransCmd) bool

func ProcessTransResult

func ProcessTransResult(tid, childtid TransNodeID, retCode int, ud interface{}) bool

func ProcessTransStart

func ProcessTransStart(parentTnp, myTnp *TransNodeParam, ud interface{}, timeout time.Duration) bool

func RegisteHandler

func RegisteHandler(tt TransType, th TransHandler)

func RegisteTxCommSkeleton

func RegisteTxCommSkeleton(name string, tcs TransactCommSkeleton)

func SendTranscatResume

func SendTranscatResume(tnode *TransNode) bool

func SendTranscatYield

func SendTranscatYield(tnode *TransNode) bool

func Stats

func Stats() map[int]TransStats

Types

type Configuration

type Configuration struct {
	TxSkeletonName string
	// contains filtered or unexported fields
}

func (*Configuration) Close

func (this *Configuration) Close() error

func (*Configuration) Init

func (this *Configuration) Init() error

func (*Configuration) Name

func (this *Configuration) Name() string

type OnChildRespWrapper

type OnChildRespWrapper func(n *TransNode, hChild TransNodeID, retCode int, ud interface{}) TransExeResult

type OnCommitWrapper

type OnCommitWrapper func(n *TransNode) TransExeResult

type OnExecuteWrapper

type OnExecuteWrapper func(n *TransNode, ud interface{}) TransExeResult

type OnRollBackWrapper

type OnRollBackWrapper func(n *TransNode) TransExeResult

type TransBrotherNotify

type TransBrotherNotify func(*TransNode, TransExeResult)

type TransCallback

type TransCallback func(*TransNode)

type TransCmd

type TransCmd int
const (
	///transact command type
	TransCmd_Invalid TransCmd = iota
	TransCmd_Commit
	TransCmd_RollBack
)

type TransCtx

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

func NewTransCtx

func NewTransCtx() *TransCtx

func (*TransCtx) GetField

func (this *TransCtx) GetField(k interface{}) interface{}

func (*TransCtx) SetField

func (this *TransCtx) SetField(k, v interface{})

type TransExeResult

type TransExeResult int
const (
	///transact result
	TransExeResult_Success TransExeResult = iota
	TransExeResult_Failed
	TransExeResult_Yield
	TransExeResult_NullPointer
	TransExeResult_NoStart
	TransExeResult_NoSetHandler
	TransExeResult_ChildNodeNotExist
	TransExeResult_ChildNodeRepeateRet
	TransExeResult_AsynFailed
	TransExeResult_HadDone
	TransExeResult_StartChildFailed
	TransExeResult_UnsafeExecuteEnv
)

type TransHanderWrapper

func (*TransHanderWrapper) OnChildTransRep

func (wrapper *TransHanderWrapper) OnChildTransRep(n *TransNode, hChild TransNodeID, retCode int, ud interface{}) TransExeResult

func (*TransHanderWrapper) OnCommit

func (wrapper *TransHanderWrapper) OnCommit(n *TransNode) TransExeResult

func (*TransHanderWrapper) OnExcute

func (wrapper *TransHanderWrapper) OnExcute(n *TransNode, ud interface{}) TransExeResult

func (*TransHanderWrapper) OnRollBack

func (wrapper *TransHanderWrapper) OnRollBack(n *TransNode) TransExeResult

type TransHandler

type TransHandler interface {
	OnExcute(n *TransNode, ud interface{}) TransExeResult
	OnCommit(n *TransNode) TransExeResult
	OnRollBack(n *TransNode) TransExeResult
	OnChildTransRep(n *TransNode, hChild TransNodeID, retCode int, ud interface{}) TransExeResult
}

func GetHandler

func GetHandler(tt TransType) TransHandler

type TransNode

type TransNode struct {
	TransEnv  *TransCtx
	TransRep  *TransResult
	MyTnp     *TransNodeParam
	ParentTnp *TransNodeParam

	Childs map[TransNodeID]*TransNodeParam

	AsynCallback TransCallback
	// contains filtered or unexported fields
}

func (*TransNode) GetChildTransParam

func (this *TransNode) GetChildTransParam(childid TransNodeID) *TransNodeParam

func (*TransNode) Go

func (this *TransNode) Go(obj *basic.Object) TransExeResult

func (*TransNode) MakeBrotherWith

func (this *TransNode) MakeBrotherWith(brother *TransNode, tbn TransBrotherNotify)

func (*TransNode) Resume

func (this *TransNode) Resume() TransExeResult

func (*TransNode) StartChildTrans

func (this *TransNode) StartChildTrans(tnp *TransNodeParam, ud interface{}, timeout time.Duration) TransExeResult

func (*TransNode) Yield

func (this *TransNode) Yield() TransExeResult

type TransNodeID

type TransNodeID int64

type TransNodeParam

type TransNodeParam struct {
	TId        TransNodeID
	Tt         TransType
	Ot         TransOwnerType
	Tct        TransactCommitPolicy
	Oid        int
	SkeletonID int
	LevelNo    int
	AreaID     int
	TimeOut    time.Duration
}

type TransOwnerType

type TransOwnerType int
const (
	///transact owner type
	TransOwnerType_Invalid TransOwnerType = iota
	TransOwnerType_Max
)

type TransResult

type TransResult struct {
	RetCode  int
	RetFiels interface{}
}

type TransStats

type TransStats struct {
	ExecuteTimes    int64
	RollbackTimes   int64
	CommitTimes     int64
	TimeoutTimes    int64
	YieldTimes      int64
	ResumeTimes     int64
	TotalRuningTime int64
	MaxRuningTime   int64
}

type TransType

type TransType int

type TransactCommSkeleton

type TransactCommSkeleton interface {
	SendTransResult(parent, me *TransNodeParam, tr *TransResult) bool
	SendTransStart(parent, me *TransNodeParam, ud interface{}) bool
	SendCmdToTransNode(tnp *TransNodeParam, cmd TransCmd) bool
	GetSkeletonID() int
	GetAreaID() int
}

func GetTxCommSkeleton

func GetTxCommSkeleton(name string) TransactCommSkeleton

type TransactCommitPolicy

type TransactCommitPolicy int
const (
	TransactCommitPolicy_SelfDecide TransactCommitPolicy = iota
	TransactCommitPolicy_TwoPhase
)

Jump to

Keyboard shortcuts

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