generated from openacid/gotmpl
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinternal_api.go
44 lines (34 loc) · 912 Bytes
/
internal_api.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package traft
import "context"
func (tr *TRaft) Elect(ctx context.Context, req *ElectReq) (*ElectReply, error) {
var reply *ElectReply
rst := tr.query( func() error {
reply= tr.hdlElectReq(req)
return nil
})
_ = rst
return reply,nil
}
func (tr *TRaft) LogForward(ctx context.Context, req *LogForwardReq) (*LogForwardReply, error) {
// TODO: if a newer committer is seen, non-committed logs
// can be sure to stale and should be cleaned.
var reply *LogForwardReply
rst := tr.query( func() error {
reply = tr.hdlLogForward(req)
return nil
})
_ = rst
return reply, nil
}
func (tr *TRaft) Propose(ctx context.Context, cmd *Cmd) (*ProposeReply, error) {
finCh := make(chan *ProposeReply, 1)
rst := tr.query( func() error {
tr.hdlPropose(cmd, finCh)
return nil
})
_ = rst
lg.Infow("waitingFor:finCh")
reply := <-finCh
lg.Infow("got:finCh", "reply", reply)
return reply, nil
}