Draft of new server.go
xiang90 opened this issue · 3 comments
benbjohnson commented
@xiangli-cmu That's basically what I was thinking too. Looks good. Just a couple notes:
- Do we need separate goroutines for
sendAndCollectVotes
andcommitCenter
? It seems like those could be combined into thecandidate
andleader
functions without spawning off something asynchronous. - Can you rename the functions to be verbs? e.g.
follower()
->follow()
,candidate()
->promote()
,leader()
->lead()
? - Change the constants to be initial-case:
LEADER
->Leader
. Go doesn't typically use all-caps.
xiang90 commented
For 1, probably we can do them in one select.
For 2 and 3, I will do it when I am going to write the codes.
What do you think about this structure?
benbjohnson commented
@xiangli-cmu I think the structure looks great. Go for it.