forked from runabol/tork
-
Notifications
You must be signed in to change notification settings - Fork 0
/
node.go
42 lines (36 loc) · 1.08 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
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"`
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"`
Version string `json:"version"`
}
func (n *Node) Clone() *Node {
return &Node{
ID: n.ID,
StartedAt: n.StartedAt,
CPUPercent: n.CPUPercent,
LastHeartbeatAt: n.LastHeartbeatAt,
Queue: n.Queue,
Status: n.Status,
Hostname: n.Hostname,
TaskCount: n.TaskCount,
Version: n.Version,
}
}