-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathnode.go
59 lines (51 loc) · 1.59 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
47
48
49
50
51
52
53
54
55
56
57
58
59
package pool
import "github.com/qa-dev/jsonwire-grid/pool/capabilities"
type NodeStatus string
const (
NodeStatusAvailable NodeStatus = "available"
NodeStatusReserved NodeStatus = "reserved"
NodeStatusBusy NodeStatus = "busy"
)
type NodeType string
const (
NodeTypePersistent NodeType = "persistent"
NodeTypeKubernetes NodeType = "kubernetes"
)
type Node struct {
// A unique key, by which we understand how to find this object in the outer world + for not adding the second time the same thing.
// The value may depend on the strategy:
// - for constant nodes ip: port
// - for temporary pod.name
Key string `json:"key" bson:"key"`
Type NodeType `json:"type" bson:"type"`
Address string `json:"address" bson:"address"`
Status NodeStatus `json:"status" bson:"status"`
SessionID string `json:"session_id" bson:"session_id"`
Updated int64 `json:"updated" bson:"updated"`
Registered int64 `json:"registered" bson:"registered"`
CapabilitiesList []capabilities.Capabilities `json:"capabilities_list" bson:"capabilities_list"`
}
func (n *Node) String() string {
return "Node [" + n.Key + "]"
}
func NewNode(
key string,
t NodeType,
address string,
status NodeStatus,
sessionID string,
updated int64,
registered int64,
capabilitiesList []capabilities.Capabilities,
) *Node {
return &Node{
key,
t,
address,
status,
sessionID,
updated,
registered,
capabilitiesList,
}
}