forked from docker-archive/classicswarm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
node.go
35 lines (27 loc) · 949 Bytes
/
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
package cluster
import "fmt"
// Node is exported
type Node interface {
ID() string
Name() string
IP() string //to inject the actual IP of the machine in docker ps (hostname:port or ip:port)
Addr() string //to know where to connect with the proxy
Images() []*Image //used by the API
Image(IDOrName string) *Image //used by the filters
Containers() []*Container //used by the filters
Container(IDOrName string) *Container //used by the filters
TotalCpus() int64 //used by the strategy
UsedCpus() int64 //used by the strategy
TotalMemory() int64 //used by the strategy
UsedMemory() int64 //used by the strategy
Labels() map[string]string //used by the filters
IsHealthy() bool
}
// SerializeNode is exported
func SerializeNode(node Node) string {
return fmt.Sprintf("{%q:%q,%q:%q,%q:%q,%q:%q}",
"Name", node.Name(),
"Id", node.ID(),
"Addr", node.Addr(),
"Ip", node.IP())
}