-
Notifications
You must be signed in to change notification settings - Fork 0
/
structs.go
165 lines (129 loc) · 2.79 KB
/
structs.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
package main
import "sync"
type SocketConfig struct {
Datapoints []*Vector
}
type Vector struct {
Axis VectorAxis
Tag string
Namespace string
Type VectorType
Interval VectorInterval
DataType VectorDataType
}
type VectorAxis string
const (
X VectorAxis = "x"
Y VectorAxis = "y"
Z VectorAxis = "z"
)
type VectorDataType string
const (
I VectorDataType = "int"
F VectorDataType = "float"
)
type VectorType string
const (
MIN VectorType = "min"
MAX VectorType = "max"
SUM VectorType = "sum"
MEAN VectorType = "mean"
)
type VectorInterval string
const (
S5 VectorInterval = "5sec"
S10 VectorInterval = "10sec"
S30 VectorInterval = "30sec"
M1 VectorInterval = "1min"
M5 VectorInterval = "5min"
M10 VectorInterval = "10min"
M30 VectorInterval = "30min"
HR1 VectorInterval = "1hr"
)
// DATACENTER STUFF
// DATACENTER STUFF
// DATACENTER STUFF
// DATACENTER STUFF
// DATACENTER STUFF
// DATACENTER STUFF
type Datacenter struct {
ID int `json:"ID"`
Tag string `json:"Tag"`
Info string `json:"Info"`
}
type Row struct {
ID int `json:"ID"`
Tag string `json:"Tag"`
Info string `json:"Info"`
DCID int `json:"DatacenterID"`
}
type Rack struct {
ID int `json:"ID"`
Tag string `json:"Tag"`
Info string `json:"Info"`
RowID int `json:"RowID"`
TotalU int `json:"TotalU"`
BreakerLimit int `json:"BreakerLimit"`
PowerType PowerType `json:"PowerType"`
// PowerWarning int `json:"BreakerWarning"`
// ???
// Visual
Color string `json:"Color"`
}
type Unit struct {
ID int `json:"ID"`
Info string `json:"Info"`
Tag string `json:"Tag"`
RackID int `json:"RackID"`
BMC string `json:"BMC"`
SSH string `json:"SSH"`
IPs []string `json:"IPs"`
Networks []*Network `json:"Networks"`
// Visual
Size int `json:"Size"`
Color string `json:"Color"`
}
type Connection struct {
ID int `json:"ID"`
Info string `json:"Info"`
Tag string `json:"Tag"`
From int `json:"From"`
To int `json:"To"`
// Visual
Color string `json:"Color"`
}
type Network struct {
ID int `json:"ID"`
Info string `json:"Info"`
Tag string `json:"Tag"`
CIDR string `json:"CIDR"`
}
type PowerType string
const (
AC PowerType = "ac"
DC PowerType = "dc"
)
// DATACENTER STUFF
// DATACENTER STUFF
// DATACENTER STUFF
// DATACENTER STUFF
// DATACENTER STUFF
// DATACENTER STUFF
type ConnectedSocket struct {
Config SocketConfig
}
var (
globalSocketsM = make(map[string]*ConnectedSocket)
mutex sync.Mutex
)
func SetConnectedSocket(key string, socket *ConnectedSocket) {
mutex.Lock()
defer mutex.Unlock()
globalSocketsM[key] = socket
}
func GetConnectedSocket(key string) (*ConnectedSocket, bool) {
mutex.Lock()
defer mutex.Unlock()
socket, exists := globalSocketsM[key]
return socket, exists
}