-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.go
77 lines (62 loc) · 1.65 KB
/
types.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package nodes
import (
"github.com/geolocate-orchestration/gountries"
)
// INodes exports all node controller public methods
type INodes interface {
CountNodes() int
GetAllNodes() []*Node
GetNodes(filter *NodeFilter) []*Node
AddNode(node *Node)
UpdateNode(oldNode *Node, newNode *Node)
DeleteNode(node *Node)
}
// New create a new Nodes struct
func New() INodes {
nodes := Nodes{
Query: gountries.New(),
ContinentsList: gountries.NewContinents(),
Nodes: make([]*Node, 0),
Cities: make(map[string][]*Node),
Countries: make(map[string][]*Node),
Continents: make(map[string][]*Node),
}
return &nodes
}
// Nodes controls in-cache nodes
type Nodes struct {
Query *gountries.Query
ContinentsList gountries.Continents
Nodes []*Node
Cities map[string][]*Node
Countries map[string][]*Node
Continents map[string][]*Node
}
// Node represents a cluster Node
type Node struct {
// Name represents Node unique identifying name
Name string
// Labels represents all of Node labels
Labels map[string]string
// CPU represents Node available CPU resources in MilliValue
CPU int64
// Memory represents Node available Memory resources in MilliValue
Memory int64
}
// NodeFilter states the params which nodes must match to be returned
type NodeFilter struct {
Labels map[string]string
Resources Resources
Locations Locations
}
// Resources states the available resources nodes must have to be returned
type Resources struct {
CPU int64
Memory int64
}
// Locations states the location params nodes must match to be returned
type Locations struct {
Cities []string
Countries []string
Continents []string
}