forked from runabol/tork
-
Notifications
You must be signed in to change notification settings - Fork 0
/
node.go
44 lines (38 loc) · 1.17 KB
/
node.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
package tork
import (
"time"
)
var LAST_HEARTBEAT_TIMEOUT = time.Minute * 5
var HEARTBEAT_RATE = time.Second * 30
type NodeStatus string
const (
NodeStatusUP NodeStatus = "UP"
NodeStatusDown NodeStatus = "DOWN"
NodeStatusOffline NodeStatus = "OFFLINE"
)
type Node struct {
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
StartedAt time.Time `json:"startedAt,omitempty"`
CPUPercent float64 `json:"cpuPercent,omitempty"`
LastHeartbeatAt time.Time `json:"lastHeartbeatAt,omitempty"`
Queue string `json:"queue,omitempty"`
Status NodeStatus `json:"status,omitempty"`
Hostname string `json:"hostname,omitempty"`
TaskCount int `json:"taskCount,omitempty"`
Version string `json:"version"`
}
func (n *Node) Clone() *Node {
return &Node{
ID: n.ID,
Name: n.Name,
StartedAt: n.StartedAt,
CPUPercent: n.CPUPercent,
LastHeartbeatAt: n.LastHeartbeatAt,
Queue: n.Queue,
Status: n.Status,
Hostname: n.Hostname,
TaskCount: n.TaskCount,
Version: n.Version,
}
}