From 6120fa634ee9f8b15d2e915e0d64d50ec3c23fed Mon Sep 17 00:00:00 2001 From: Xiang Li Date: Sun, 11 Aug 2013 11:40:45 -0700 Subject: [PATCH] remove duplicate codes --- etcd_handlers.go | 4 ++-- machines.go | 14 -------------- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/etcd_handlers.go b/etcd_handlers.go index b391f2ada..dec24031e 100644 --- a/etcd_handlers.go +++ b/etcd_handlers.go @@ -218,14 +218,14 @@ func MachinesHttpHandler(w http.ResponseWriter, req *http.Request) { // Add itself to the machine list first // Since peer map does not contain the server itself - machines, _ := getEtcdURL(raftServer.Name()) + machines, _ := nameToEtcdURL(raftServer.Name()) // Add all peers to the list and separate by comma // We do not use json here since we accept machines list // in the command line separate by comma. for peerName, _ := range peers { - if addr, ok := getEtcdURL(peerName); ok { + if addr, ok := nameToEtcdURL(peerName); ok { machines = machines + "," + addr } } diff --git a/machines.go b/machines.go index 0b6681f3f..3b4fc39db 100644 --- a/machines.go +++ b/machines.go @@ -5,20 +5,6 @@ import ( "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")