Repetetive broadcast of raft join request message until a join signal is received on a dedicated channel.

Handle multiple types of Actions in NotifyMsg.
Added function to check if the current server is the raft leader.
This commit is contained in:
Kelvin Clement Mwinuka
2023-07-30 20:31:56 +08:00
parent d82a6a98d7
commit 094d44c9a0
3 changed files with 63 additions and 12 deletions

View File

@@ -34,7 +34,8 @@ type Server struct {
broadcastQueue *memberlist.TransmitLimitedQueue
numOfNodes int
cancelCh *chan (os.Signal)
cancelCh *chan (os.Signal)
raftJoinCh *chan (struct{})
}
func (server *Server) Lock() {
@@ -201,9 +202,10 @@ func main() {
cancelCh := make(chan (os.Signal), 1)
signal.Notify(cancelCh, syscall.SIGINT, syscall.SIGTERM)
raftJoinCh := make(chan struct{})
server := &Server{
cancelCh: &cancelCh,
config: config,
config: config,
broadcastQueue: new(memberlist.TransmitLimitedQueue),
numOfNodes: 0,
@@ -213,6 +215,9 @@ func main() {
NewSetGetCommand(),
NewListCommand(),
},
cancelCh: &cancelCh,
raftJoinCh: &raftJoinCh,
}
go server.Start()