Blake Mizerany 11 years ago
parent
commit
576e26ea39
1 changed files with 7 additions and 9 deletions
  1. 7 9
      main.go

+ 7 - 9
main.go

@@ -6,7 +6,6 @@ import (
 	"net/http"
 	"strconv"
 	"time"
-	"code.google.com/p/go.net/context"
 
 	etcdserver "github.com/coreos/etcd/etcdserver2"
 	"github.com/coreos/etcd/etcdserver2/etcdhttp"
@@ -39,16 +38,15 @@ func main() {
 		log.Fatalf("%d=<addr> must be specified in peers", id)
 	}
 
-	n := raft.Start(id, peers.Ids())
-
-	ctx, _ := context.WithTimeout(context.Background(), 10*time.Second)
-	n.Campaign(ctx)
+	n := raft.Start(id, peers.Ids(), 10, 1)
 
+	tk := time.NewTicker(100 * time.Millisecond)
 	s := &etcdserver.Server{
-		Store: store.New(),
-		Node:  n,
-		Save:  func(st raftpb.State, ents []raftpb.Entry) {}, // TODO: use wal
-		Send:  etcdhttp.Sender(peers),
+		Store:  store.New(),
+		Node:   n,
+		Save:   func(st raftpb.State, ents []raftpb.Entry) {}, // TODO: use wal
+		Send:   etcdhttp.Sender(peers),
+		Ticker: tk.C,
 	}
 	etcdserver.Start(s)
 	h := &etcdhttp.Handler{