Raft Lab 2
The Raft Interface
先bb一下:要implement任何东西,都必须先搞清楚它的interface。在实际开发中和客户交流基本上就是决定一个合理的interface。
func Make(peers []*labrpc.ClientEnd, me int, persister *Persister, applyCh chan ApplyMsg) *Raft
Make()创建一个新的raft peer(服务器)。
func (rf *Raft) Start(command interface{}) (int, int, bool)
服务(比如kv server)调用Start(command)来新建一个command。
rf.GetState() (term, isLeader)
ask a Raft for its current term, and whether it thinks it is leader
ApplyMsg struct
applyCh chan
Each time a new entry is committed to the log, each Raft peer should send an ApplyMsg to the service in the same server. 顾名思义,这个message就是和上层服务说:我log已经committed了,你可以安全地把log里面的command给apply掉。
#