File tree 4 files changed +13
-2
lines changed
4 files changed +13
-2
lines changed Original file line number Diff line number Diff line change 1
1
# go-saga
2
2
3
- [ ![ GoDoc] ( https://godoc.org/github.com/lysu/go-saga?status.svg )] ( https://godoc.org/github.com/lysu/go-saga ) [ ![ Build Status] ( https://travis-ci.org/lysu/go-saga.svg?branch=master )] ( https://travis-ci.org/lysu/go-saga )
3
+ [ ![ GoDoc] ( https://godoc.org/github.com/lysu/go-saga?status.svg )] ( https://godoc.org/github.com/lysu/go-saga )
4
+ [ ![ Build Status] ( https://travis-ci.org/lysu/go-saga.svg?branch=master )] ( https://travis-ci.org/lysu/go-saga )
4
5
5
6
Implements sagas-pattern in go, make distribute transaction easier.
6
7
Original file line number Diff line number Diff line change @@ -13,6 +13,8 @@ const (
13
13
SagaStart LogType = iota + 1
14
14
// SagaEnd flag saga ended log
15
15
SagaEnd
16
+ // SagaAbort flag saga aborted
17
+ SagaAbort
16
18
// ActionStart flag action start log
17
19
ActionStart
18
20
// ActionEnd flag action end log
Original file line number Diff line number Diff line change @@ -86,6 +86,14 @@ func (s *Saga) Abort() {
86
86
if err != nil {
87
87
panic ("Abort Panic" )
88
88
}
89
+ alog := & Log {
90
+ Type : SagaAbort ,
91
+ Time : time .Now (),
92
+ }
93
+ err = s .sec .logStorage .AppendLog (s .logID , alog .mustMarshal ())
94
+ if err != nil {
95
+ panic ("Add log Failure" )
96
+ }
89
97
for i := len (logs ) - 1 ; i >= 0 ; i -- {
90
98
logData := logs [i ]
91
99
log := mustUnmarshalLog (logData )
Original file line number Diff line number Diff line change @@ -77,7 +77,7 @@ func TestDepositFail(t *testing.T) {
77
77
logs , err := storage .Lookup ("saga_1" )
78
78
assert .NoError (t , err )
79
79
t .Logf ("%v" , logs )
80
- assert .Equal (t , 9 , len (logs ))
80
+ assert .Equal (t , 10 , len (logs ))
81
81
82
82
}
83
83
You can’t perform that action at this time.
0 commit comments