mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
remove duplicate codes
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
14
machines.go
14
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")
|
||||
|
||||
Reference in New Issue
Block a user