-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathss_mux.go
56 lines (44 loc) · 1.15 KB
/
ss_mux.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
54
55
56
package states
import (
am "github.com/pancsta/asyncmachine-go/pkg/machine"
"github.com/pancsta/asyncmachine-go/pkg/states"
)
// MuxStatesDef contains all the states of the Mux state machine.
// The target state is PortInfo, activated by an aRPC client.
type MuxStatesDef struct {
// shadow duplicated StatesBase
*am.StatesBase
// basics
// Ready - mux is ready to accept new clients.
Ready string
ClientConnected string
HasClients string
// NewServerErr - new server returned an error. The mux is still running.
NewServerErr string
// inherit from BasicStatesDef
*states.BasicStatesDef
}
// MuxStruct represents all relations and properties of MuxStatesDef.
var MuxStruct = states.StructMerge(
states.BasicStruct,
am.Struct{
ssD.Exception: {
Multi: true,
Remove: S{ssS.Ready},
},
ssD.Ready: {
Require: S{ssS.Start},
},
ssD.ClientConnected: {
Multi: true,
Require: states.S{ssD.Start},
},
ssD.HasClients: {Require: states.S{ssD.Start}},
ssD.NewServerErr: {},
})
// EXPORTS AND GROUPS
var (
ssD = am.NewStates(MuxStatesDef{})
// MuxStates contains all the states for the Mux machine.
MuxStates = ssD
)