-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroute_runner.go
53 lines (38 loc) · 1.07 KB
/
route_runner.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
50
51
52
53
package orchestrator
type routeRunner struct {
// runner id
id string
// route root State
routeRootState *State
// recovery route root State
recoveryRootState *State
// statemachine ...
statemachine *statemachine
}
func newRouteRunner(routeRootState *State, recoveryRootState *State) *routeRunner {
return &routeRunner{
routeRootState: routeRootState,
recoveryRootState: recoveryRootState,
statemachine: &statemachine{},
}
}
func (rr *routeRunner) run(ctx *context, errCh chan<- error) {
var err error
rr.statemachine.init(rr.routeRootState, ctx)
for hasNext := true; hasNext == true; hasNext, err = rr.statemachine.doAction() {
mst, mctx := rr.statemachine.getMemento()
if errCh != nil && err != nil {
errCh <- err
}
// call error recovery handler
if err != nil && rr.recoveryRootState != nil {
rr.statemachine.init(rr.recoveryRootState, &mctx)
for rcHasNext := true; rcHasNext == true; rcHasNext, err = rr.statemachine.doAction() {
errCh <- err
}
rr.statemachine.init(mst, &mctx)
}
}
}
func (rr *routeRunner) shutdown() {
}