From 875e7c7e774fd5f2708cd9a1de9143144da9a960 Mon Sep 17 00:00:00 2001 From: Victor Vieux Date: Thu, 11 Dec 2014 01:39:20 +0000 Subject: [PATCH] add discovery/README.md --- discovery/README.md | 24 ++++++++++++++++++++++++ discovery/etcd/etcd.go | 2 ++ 2 files changed, 26 insertions(+) create mode 100644 discovery/README.md 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