forked from docker-archive/classicswarm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nodes.go
45 lines (36 loc) · 929 Bytes
/
nodes.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
package nodes
import (
"strings"
"github.com/docker/swarm/discovery"
)
// NodesDiscoveryService is exported
type NodesDiscoveryService struct {
entries []*discovery.Entry
}
func init() {
discovery.Register("nodes", &NodesDiscoveryService{})
}
// Initialize is exported
func (s *NodesDiscoveryService) Initialize(uris string, _ int) error {
for _, input := range strings.Split(uris, ",") {
for _, ip := range discovery.Generate(input) {
entry, err := discovery.NewEntry(ip)
if err != nil {
return err
}
s.entries = append(s.entries, entry)
}
}
return nil
}
// Fetch is exported
func (s *NodesDiscoveryService) Fetch() ([]*discovery.Entry, error) {
return s.entries, nil
}
// Watch is exported
func (s *NodesDiscoveryService) Watch(callback discovery.WatchCallback) {
}
// Register is exported
func (s *NodesDiscoveryService) Register(addr string) error {
return discovery.ErrNotImplemented
}