Blake Mizerany 11 years ago
parent
commit
728690fa03
2 changed files with 7 additions and 0 deletions
  1. 3 0
      etcdserver2/etcdhttp/http.go
  2. 4 0
      main.go

+ 3 - 0
etcdserver2/etcdhttp/http.go

@@ -30,6 +30,9 @@ type Peers map[int64][]string
 
 func (ps Peers) Pick(id int64) string {
 	addrs := ps[id]
+	if len(addrs) == 0 {
+		return ""
+	}
 	return fmt.Sprintf("http://%s", addrs[rand.Intn(len(addrs))])
 }
 

+ 4 - 0
main.go

@@ -34,6 +34,10 @@ func main() {
 		log.Fatal(err)
 	}
 
+	if peers.Pick(id) == "" {
+		log.Fatalf("%d=<addr> must be specified in peers", id)
+	}
+
 	n := raft.Start(id, peers.Ids())
 	s := &etcdserver.Server{
 		Store: store.New(),