diff --git a/discovery/README.md b/discovery/README.md new file mode 100644 index 0000000000..34c1a78ea0 --- /dev/null +++ b/discovery/README.md @@ -0,0 +1,24 @@ +Discovery +========= + +Contributing a new discovery backend is easy, +simply implements this interface: + +```go +type DiscoveryService interface { + Fetch() ([]string, error) + Watch(int) <-chan time.Time + Register(string) error +} +``` + +######Fetch +returns the list of all the nodes from the discovery + +######Watch +triggers when you need to update (`Fetch`) the list of nodes, +it can happen either via un timer (like `token`) or use +backend specific features (like `etcd`) + +######Register +add a new node to the discovery diff --git a/discovery/etcd/etcd.go b/discovery/etcd/etcd.go index 33afafc54c..a8cbfb4a53 100644 --- a/discovery/etcd/etcd.go +++ b/discovery/etcd/etcd.go @@ -23,6 +23,8 @@ func init() { func Init(uris string) (discovery.DiscoveryService, error) { var ( + // split here because uris can contain multiples ips + // like `etcd://192.168.0.1,192.168.0.2,192.168.0.3/path` parts = strings.SplitN(uris, "/", 2) ips = strings.Split(parts[0], ",") machines []string