-
Notifications
You must be signed in to change notification settings - Fork 5
/
config.go
103 lines (95 loc) · 1.86 KB
/
config.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
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
package stadis
import "time"
var DefaultConfig = []byte(`
{
"DcDefault":{"Latency":100000000},
"RackDefault":{"Latency":10000000},
"HostDefault":{"Latency":1000000},
"DataCenters":[
{
"Name":"animal",
"Racks":[
{
"Name":"land",
"Hosts":[{"Name":"tiger"},{"Name":"lion"},{"Name":"wolf"}]
},
{
"Name":"sea",
"Hosts":[{"Name":"shark"},{"Name":"whale"},{"Name":"cod"}]
},
{
"Name":"air",
"Hosts":[{"Name":"eagle"},{"Name":"crow"},{"Name":"owl"}]
}
]
},
{
"Name":"plant",
"Racks":[
{
"Name":"fruit",
"Hosts":[{"Name":"apple"},{"Name":"pear"},{"Name":"grape"}]
},
{
"Name":"crop",
"Hosts":[{"Name":"corn"},{"Name":"rice"},{"Name":"wheat"}]
},
{
"Name":"flower",
"Hosts":[{"Name":"rose"},{"Name":"lily"},{"Name":"lotus"}]
}
]
},
{
"Name":"matter",
"Racks":[
{
"Name":"metal",
"Hosts":[{"Name":"gold"},{"Name":"silver"},{"Name":"iron"}]
},
{
"Name":"gem",
"Hosts":[{"Name":"ruby"},{"Name":"ivory"},{"Name":"pearl"}]
},
{
"Name":"liquid",
"Hosts":[{"Name":"water"},{"Name":"oil"},{"Name":"wine"}]
}
]
}
]
}
`)
type ConnState struct {
Latency time.Duration //the sleep time before write data to the connection.
OK bool //If not ok, local process should not write data to the connection.
}
type NodeState struct {
Latency time.Duration
InternalDown bool
ExternalDown bool
}
type Config struct {
DcDefault *NodeState
RackDefault *NodeState
HostDefault *NodeState
DataCenters []*DataCenter
}
type DataCenter struct {
RackDefault *NodeState
HostDefault *NodeState
Name string
Racks []*Rack
*NodeState
}
type Rack struct {
HostDefault *NodeState
Name string
Hosts []*Host
*NodeState
}
type Host struct {
Name string
Ports []int
*NodeState
}