-
Notifications
You must be signed in to change notification settings - Fork 40
/
node.go
46 lines (40 loc) · 1.24 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
45
46
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"`
Port int `json:"port,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,
Port: n.Port,
TaskCount: n.TaskCount,
Version: n.Version,
}
}