mirror of https://github.com/docker/docs.git
add discovery/README.md
This commit is contained in:
parent
c38f621425
commit
875e7c7e77
|
@ -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
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue