mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
28 lines
468 B
Go
28 lines
468 B
Go
package main
|
|
|
|
import (
|
|
"net/url"
|
|
"path"
|
|
)
|
|
|
|
func getEtcdURL(name string) (string, bool) {
|
|
resps, _ := etcdStore.RawGet(path.Join("_etcd/machines", name))
|
|
|
|
m, err := url.ParseQuery(resps[0].Value)
|
|
|
|
if err != nil {
|
|
panic("Failed to parse machines entry")
|
|
}
|
|
|
|
addr := m["etcd"][0]
|
|
|
|
return addr, true
|
|
}
|
|
|
|
// machineNum returns the number of machines in the cluster
|
|
func machineNum() int {
|
|
response, _ := etcdStore.RawGet("_etcd/machines")
|
|
|
|
return len(response)
|
|
}
|