machines.go 471 B

123456789101112131415161718192021222324252627
  1. package main
  2. import (
  3. "net/url"
  4. "path"
  5. )
  6. func getClientAddr(name string) (string, bool) {
  7. resps, _ := etcdStore.RawGet(path.Join("_etcd/machines", name))
  8. m, err := url.ParseQuery(resps[0].Value)
  9. if err != nil {
  10. panic("Failed to parse machines entry")
  11. }
  12. addr := m["etcd"][0]
  13. return addr, true
  14. }
  15. // machineNum returns the number of machines in the cluster
  16. func machineNum() int {
  17. response, _ := etcdStore.RawGet("_etcd/machines")
  18. return len(response)
  19. }