raft: remove sync

We don't need SyncNode. We only care about things that have made it
through the store. We can do this there.
release-2.0
Blake Mizerany 2014-08-21 00:27:21 -07:00 committed by Yicheng Qin
parent ce7536e564
commit 8d37587e47
1 changed files with 0 additions and 41 deletions

View File

@ -1,41 +0,0 @@
package raft
import (
"code.google.com/p/go.net/context"
"github.com/coreos/etcd/wait"
)
type SyncNode struct {
n *Node
w wait.WaitList
}
func NewSyncNode(n *Node) *SyncNode { panic("not implemented") }
type waitResp struct {
e Entry
err error
}
func (n *SyncNode) Propose(ctx context.Context, id int64, data []byte) (Entry, error) {
ch := n.w.Register(id)
n.n.Propose(id, data)
select {
case x := <-ch:
wr := x.(waitResp)
return wr.e, wr.err
case <-ctx.Done():
n.w.Trigger(id, nil) // GC the Wait
return Entry{}, ctx.Err()
}
}
func (n *SyncNode) ReadState() (State, []Entry, []Message, error) {
st, ents, msgs, err := n.n.ReadState()
for _, e := range ents {
if e.Index >= st.CommitIndex {
n.w.Trigger(e.Id, waitResp{e: e, err: nil})
}
}
return st, ents, msgs, err
}