-
Notifications
You must be signed in to change notification settings - Fork 0
/
transhandler.go
49 lines (42 loc) · 1.51 KB
/
transhandler.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// transhandler
package transact
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
}
type OnExecuteWrapper func(n *TransNode, ud interface{}) TransExeResult
type OnCommitWrapper func(n *TransNode) TransExeResult
type OnRollBackWrapper func(n *TransNode) TransExeResult
type OnChildRespWrapper func(n *TransNode, hChild TransNodeID, retCode int, ud interface{}) TransExeResult
type TransHanderWrapper struct {
OnExecuteWrapper
OnCommitWrapper
OnRollBackWrapper
OnChildRespWrapper
}
func (wrapper *TransHanderWrapper) OnExcute(n *TransNode, ud interface{}) TransExeResult {
if wrapper.OnExecuteWrapper != nil {
return wrapper.OnExecuteWrapper(n, ud)
}
return TransExeResult_Success
}
func (wrapper *TransHanderWrapper) OnCommit(n *TransNode) TransExeResult {
if wrapper.OnCommitWrapper != nil {
return wrapper.OnCommitWrapper(n)
}
return TransExeResult_Success
}
func (wrapper *TransHanderWrapper) OnRollBack(n *TransNode) TransExeResult {
if wrapper.OnRollBackWrapper != nil {
return wrapper.OnRollBackWrapper(n)
}
return TransExeResult_Success
}
func (wrapper *TransHanderWrapper) OnChildTransRep(n *TransNode, hChild TransNodeID, retCode int, ud interface{}) TransExeResult {
if wrapper.OnChildRespWrapper != nil {
return wrapper.OnChildRespWrapper(n, hChild, retCode, ud)
}
return TransExeResult_Success
}