-
Notifications
You must be signed in to change notification settings - Fork 7
/
agent.go
55 lines (45 loc) · 1.24 KB
/
agent.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
package domain
// AgentStatus string of agent status
type AgentStatus string
const (
// AgentOffline offline status
AgentOffline AgentStatus = "OFFLINE"
// AgentBusy busy status
AgentBusy AgentStatus = "BUSY"
// AgentIdle idle status
AgentIdle AgentStatus = "IDLE"
)
type (
// AgentProfile token signed at server side
AgentProfile struct {
CpuNum int `json:"cpuNum"`
CpuUsage float64 `json:"cpuUsage"`
TotalMemory uint64 `json:"totalMemory"`
FreeMemory uint64 `json:"freeMemory"`
TotalDisk uint64 `json:"totalDisk"`
FreeDisk uint64 `json:"freeDisk"`
}
// AgentInit request data to get settings to server
AgentInit struct {
IsK8sCluster bool `json:"isK8sCluster"`
IsDocker bool `json:"isDocker"`
Token string `json:"token"`
Port int `json:"port"`
Os string `json:"os"`
Status string `json:"status"`
}
// AgentConfig response body of AgentInit from server
AgentConfig struct {
ExitOnIdle int `json:"exitOnIdle"` // 0 for don't exit agent on idle
}
AgentConfigResponse struct {
Response
Data *AgentConfig
}
)
func (r *AgentConfigResponse) IsOk() bool {
return r.Code == ok
}
func (r *AgentConfigResponse) GetMessage() string {
return r.Message
}