// Following function handles Incoming at Inbox from other peers.It reads those Event and forwards to StateMachine func (rn *RaftNode) check_Inbox(node cluster.Server) { for { env := <-node.Inbox() switch env.Msg.(type) { // this packet is APPENDENTRIESRESP: case APPENDENTRIESRESP: temp := env.Msg.(APPENDENTRIESRESP) rn.sm.SMchanels.netCh <- temp //this packet is APPENDENTRIESREQ: case APPENDENTRIESREQ: temp := env.Msg.(APPENDENTRIESREQ) rn.sm.SMchanels.netCh <- temp // this packet is VOTERESP case VOTERESP: // fmt.Println("VOTERESp"); temp := env.Msg.(VOTERESP) rn.sm.SMchanels.netCh <- temp case VOTEREQ: temp := env.Msg.(VOTEREQ) rn.sm.SMchanels.netCh <- temp } } } //End of check_Inbox function
//Process to listen incomming packets from other Servers. func processInbox(server cluster.Server, sm *State_Machine) { for { env := <-server.Inbox() switch env.Msg.(type) { case VoteReq: sm.CommMedium.netCh <- env.Msg case VoteResp: sm.CommMedium.netCh <- env.Msg case AppEntrReq: sm.CommMedium.netCh <- env.Msg case AppEntrResp: sm.CommMedium.netCh <- env.Msg } } }
// Following function handles Incoming at Inbox from other peers.It reads those Event and forwards to StateMachine func (rn *RaftNode) check_Inbox(node cluster.Server) { for { env := <-node.Inbox() switch env.Msg.(type) { case APPENDENTRIESRESP: temp := env.Msg.(APPENDENTRIESRESP) rn.sm.SMchanels.netCh <- temp case APPENDENTRIESREQ: temp := env.Msg.(APPENDENTRIESREQ) rn.sm.SMchanels.netCh <- temp case VOTERESP: temp := env.Msg.(VOTERESP) rn.sm.SMchanels.netCh <- temp case VOTEREQ: temp := env.Msg.(VOTEREQ) rn.sm.SMchanels.netCh <- temp } } } //End of check_Inbox function