add discovery/README.md

This commit is contained in:
Victor Vieux 2014-12-11 01:39:20 +00:00
parent c38f621425
commit 875e7c7e77
2 changed files with 26 additions and 0 deletions

24
discovery/README.md Normal file
View File

@ -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

View File

@ -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