mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
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.
This commit is contained in:
parent
ce7536e564
commit
8d37587e47
@ -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
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user