Add RAFT stuff
This commit is contained in:
33
MyRaft/state.py
Normal file
33
MyRaft/state.py
Normal file
@@ -0,0 +1,33 @@
|
||||
"""This module contains the base state for all other raft states"""
|
||||
|
||||
import MyRaft.node as node
|
||||
import MyRaft.raft_pb2 as raft_pb2
|
||||
|
||||
class State:
|
||||
"""Base class to represent state of the system at any point in time.
|
||||
|
||||
Default behaviour for all messaging methods is to check if term of
|
||||
message is greater than node's term, and if so convert the current
|
||||
node to a follower.
|
||||
"""
|
||||
|
||||
def __init__(self, context: node.RaftNode):
|
||||
self._context = context
|
||||
self._currentTerm = 0
|
||||
|
||||
def heartbeat_elapsed(self):
|
||||
raise NotImplementedError
|
||||
|
||||
def rcv_RequestVote(self, request):
|
||||
raise NotImplementedError
|
||||
|
||||
def rcv_AppendEntries(self, request):
|
||||
raise NotImplementedError
|
||||
|
||||
def rcv_vote(self, request):
|
||||
raise NotImplementedError
|
||||
|
||||
def rcv_AppendEntriesResponse(self, request):
|
||||
pass
|
||||
|
||||
|
||||
Reference in New Issue
Block a user