-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbase.go
More file actions
executable file
·89 lines (69 loc) · 2.1 KB
/
Copy pathbase.go
File metadata and controls
executable file
·89 lines (69 loc) · 2.1 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package msm
import "reflect"
type State string // Name of state ; ToDo: make States able to contain their sub-FSM
type Event interface{} // pointer to any struct, json'able
type RequestPayload interface{} // pointer to any struct, json'able
type DstNotFound struct{} // Event, generated if sent request with wrong destination
type Action interface{} // func(fsm *Fsm, state State, source string, event Event)
type Guard interface{} // func(fsm *Fsm, state State, source string, event Event) bool
type Storage interface{} // DO NOT USE OBJECTS WITH TAG "json:-"
type StorageFactory interface{} // func() Storage
type None struct{} // Anonymous action, fired immediately after entering state
type TerminationCB func(id FsmID, state State)
const (
StartState State = "start"
FinishState State = "finish"
)
var (
NoAction Action = func(fsm *FSMInstance, storage Storage, state State, source string, event Event) {}
NoGuard Guard = func(fsm *FSMInstance, storage Storage, state State, source string, event Event) bool { return true }
NoStorageFactory StorageFactory = func() Storage { return &struct{}{} }
)
type TransitionKey struct {
State State
Event reflect.Type
}
type TransitionValue struct {
NewState State
Action Action
Guard Guard
}
type Transition struct {
TransitionKey
TransitionValue
}
type FsmID struct {
Fsm string
Id int64
}
type Response struct {
ID FsmID
Source string
Event Event // json
}
type ICallback interface {
NoTransition(fsm *FSMInstance, state State, source string, event Event)
ChangeState(fsm *FSMInstance, state State, source string, event Event, newState State)
AutoMigrate() error
}
type IPlugin interface {
Name() string
Process(fsm *FSMInstance, request RequestPayload)
Finish(fsm *FSMInstance)
AutoMigrate() error
}
type IFSMManager interface {
CreateFSMInstance(fsmName string) FsmID
Process(id FsmID, src string, event Event)
IsTerminated(id FsmID) bool
AutoMigrate() error
}
type TimeoutEvent struct {
}
type Ponger struct {
Event
ch chan struct{}
}
func (p *Ponger) Pong() {
close(p.ch)
}