Refactor consensus module scaffold

This commit is contained in:
Raycho Mukelov 2023-09-01 06:28:43 +03:00
parent f95937107a
commit 1f4af32358
3 changed files with 24 additions and 25 deletions

View File

@ -10,14 +10,30 @@
import protocol
import types
proc RaftNodeConsensusStartElection*(consensus: RaftConsensusModule) =
proc RaftNodeStartElection*[SmCommandType, SmStateType](node: RaftNode[SmCommandType, SmStateType]) =
discard
proc RaftNodeConsensusProcessRequestVote*(consensus: RaftConsensusModule, msg: RaftMessageRequestVote): RaftMessageRequestVoteResponse =
proc RaftNodeProcessRequestVote*[SmCommandType, SmStateType](node: RaftNode[SmCommandType, SmStateType], msg: RaftMessageRequestVote): RaftMessageRequestVoteResponse =
discard
proc RaftNodeConsensusProcessAppendEntries*(consensus: RaftConsensusModule, msg: RaftMessageAppendEntries): RaftMessageAppendEntriesResponse =
proc RaftNodeProcessAppendEntries*[SmCommandType, SmStateType](node: RaftNode[SmCommandType, SmStateType], msg: RaftMessageAppendEntries): RaftMessageAppendEntriesResponse =
discard
proc RaftNodeConsensusQuorumMin(consensus: RaftConsensusModule): bool =
proc RaftNodeQuorumMin[SmCommandType, SmStateType](node: RaftNode[SmCommandType, SmStateType]): bool =
discard
proc RaftNodeReplicateSmCommand*[SmCommandType, SmStateType](node: RaftNode[SmCommandType, SmStateType], cmd: SmCommandType) =
discard
# Private Timers Create Ops
proc RaftNodeScheduleHeartBeat[SmCommandType, SmStateType](node: RaftNode[SmCommandType, SmStateType]) =
discard
proc RaftNodeScheduleHeartBeatTimeout[SmCommandType, SmStateType](node: RaftNode[SmCommandType, SmStateType]) =
discard
proc RaftNodeScheduleElectionTimeOut[SmCommandType, SmStateType](node: RaftNode[SmCommandType, SmStateType]) =
discard
proc RaftNodeScheduleRequestVoteTimeout[SmCommandType, SmStateType](node: RaftNode[SmCommandType, SmStateType]) =
discard

View File

@ -7,11 +7,12 @@
# This file may not be copied, modified, or distributed except according to
# those terms.
import chronicles
import asyncdispatch
import types
import protocol
import consensus_module
import chronicles
import asyncdispatch
export types, protocol, consensus_module
@ -111,17 +112,4 @@ proc RaftNodeLogIndexGet[SmCommandType, SmStateType](node: RaftNode[SmCommandTyp
discard
proc RaftNodeLogEntryGet[SmCommandType, SmStateType](node: RaftNode[SmCommandType, SmStateType], logIndex: RaftLogIndex): Result[RaftNodeLogEntry[SmCommandType], string] =
discard
# Private Timers Create Ops
proc RaftNodeScheduleHeartBeat[SmCommandType, SmStateType, TimerDurationType](node: RaftNode[SmCommandType, SmStateType]) =
discard
proc RaftNodeScheduleHeartBeatTimeout[SmCommandType, SmStateType, TimerDurationType](node: RaftNode[SmCommandType, SmStateType]) =
discard
proc RaftNodeScheduleElectionTimeOut[SmCommandType, SmStateType, TimerDurationType](node: RaftNode[SmCommandType, SmStateType]) =
discard
proc RaftNodeScheduleRequestVoteTimeout[SmCommandType, SmStateType, TimerDurationType](node: RaftNode[SmCommandType, SmStateType]) =
discard
discard

View File

@ -127,11 +127,6 @@ type
# Mtx definition(s) go here
raftStateMutex*: Lock
# Modules (Algos)
consensusModule: RaftConsensusModule[SmCommandType, SmStateType]
logCompactionModule: RaftLogCompactionModule[SmCommandType, SmStateType]
membershipChangeModule: RaftMembershipChangeModule[SmCommandType, SmStateType]
# Misc
msgSendCallback*: RaftMessageSendCallback
persistentStorage: RaftNodePersistentStorage[SmCommandType, SmStateType]