| Safe Haskell | None | 
|---|---|
| Language | Haskell2010 | 
Raft.NodeState
Synopsis
- data Transition (init :: Mode) (res :: Mode) where
- StartElection :: Transition Follower Candidate
 - HigherTermFoundFollower :: Transition Follower Follower
 - RestartElection :: Transition Candidate Candidate
 - DiscoverLeader :: Transition Candidate Follower
 - HigherTermFoundCandidate :: Transition Candidate Follower
 - BecomeLeader :: Transition Candidate Leader
 - HandleClientReq :: Transition Leader Leader
 - SendHeartbeat :: Transition Leader Leader
 - DiscoverNewLeader :: Transition Leader Follower
 - HigherTermFoundLeader :: Transition Leader Follower
 - Noop :: Transition init init
 
 - data ResultState init v where
- ResultState :: Show v => Transition init res -> NodeState res v -> ResultState init v
 
 - followerResultState :: Show v => Transition init Follower -> FollowerState v -> ResultState init v
 - candidateResultState :: Show v => Transition init Candidate -> CandidateState v -> ResultState init v
 - leaderResultState :: Show v => Transition init Leader -> LeaderState v -> ResultState init v
 - data RaftNodeState v where
- RaftNodeState :: {..} -> RaftNodeState v
 
 - nodeMode :: RaftNodeState v -> Mode
 - initRaftNodeState :: RaftNodeState v
 - data NodeState (a :: Mode) v where
- NodeFollowerState :: FollowerState v -> NodeState Follower v
 - NodeCandidateState :: CandidateState v -> NodeState Candidate v
 - NodeLeaderState :: LeaderState v -> NodeState Leader v
 
 - data FollowerState v = FollowerState {}
 - data CandidateState v = CandidateState {}
 - data ClientReadReqData = ClientReadReqData {}
 - type ClientReadReqs = Map Int (ClientReadReqData, Int)
 - type ClientWriteReqCache = Map ClientId (SerialNum, Maybe Index)
 - data LeaderState v = LeaderState {}
 - setLastLogEntry :: NodeState s v -> Entries v -> NodeState s v
 - getLastLogEntry :: NodeState ns v -> LastLogEntry v
 - getLastLogEntryIndex :: NodeState ns v -> Index
 - getCommitIndex :: NodeState ns v -> Index
 - getLastAppliedAndCommitIndex :: NodeState ns v -> (Index, Index)
 - isFollower :: NodeState s v -> Bool
 - isCandidate :: NodeState s v -> Bool
 - isLeader :: NodeState s v -> Bool
 
Documentation
data Transition (init :: Mode) (res :: Mode) where Source #
All valid state transitions of a Raft node
Constructors
Instances
| Show (Transition init res) Source # | |
Defined in Raft.NodeState Methods showsPrec :: Int -> Transition init res -> ShowS # show :: Transition init res -> String # showList :: [Transition init res] -> ShowS #  | |
data ResultState init v where Source #
Existential type hiding the result type of a transition
Constructors
| ResultState :: Show v => Transition init res -> NodeState res v -> ResultState init v | 
Instances
| Show v => Show (ResultState init v) Source # | |
Defined in Raft.NodeState Methods showsPrec :: Int -> ResultState init v -> ShowS # show :: ResultState init v -> String # showList :: [ResultState init v] -> ShowS #  | |
followerResultState :: Show v => Transition init Follower -> FollowerState v -> ResultState init v Source #
candidateResultState :: Show v => Transition init Candidate -> CandidateState v -> ResultState init v Source #
leaderResultState :: Show v => Transition init Leader -> LeaderState v -> ResultState init v Source #
data RaftNodeState v where Source #
Existential type hiding the internal node state
Constructors
| RaftNodeState | |
Fields 
  | |
Instances
| Show v => Show (RaftNodeState v) Source # | |
Defined in Raft.NodeState Methods showsPrec :: Int -> RaftNodeState v -> ShowS # show :: RaftNodeState v -> String # showList :: [RaftNodeState v] -> ShowS #  | |
| Monad m => MonadState (RaftNodeState v) (RaftT v m) Source # | |
Defined in Raft.Monad Methods get :: RaftT v m (RaftNodeState v) # put :: RaftNodeState v -> RaftT v m () # state :: (RaftNodeState v -> (a, RaftNodeState v)) -> RaftT v m a #  | |
nodeMode :: RaftNodeState v -> Mode Source #
initRaftNodeState :: RaftNodeState v Source #
A node in Raft begins as a follower
data NodeState (a :: Mode) v where Source #
The volatile state of a Raft Node
Constructors
| NodeFollowerState :: FollowerState v -> NodeState Follower v | |
| NodeCandidateState :: CandidateState v -> NodeState Candidate v | |
| NodeLeaderState :: LeaderState v -> NodeState Leader v | 
data FollowerState v Source #
Constructors
| FollowerState | |
Fields 
  | |
Instances
| Show v => Show (FollowerState v) Source # | |
Defined in Raft.NodeState Methods showsPrec :: Int -> FollowerState v -> ShowS # show :: FollowerState v -> String # showList :: [FollowerState v] -> ShowS #  | |
data CandidateState v Source #
Constructors
| CandidateState | |
Fields 
  | |
Instances
| Show v => Show (CandidateState v) Source # | |
Defined in Raft.NodeState Methods showsPrec :: Int -> CandidateState v -> ShowS # show :: CandidateState v -> String # showList :: [CandidateState v] -> ShowS #  | |
data ClientReadReqData Source #
Constructors
| ClientReadReqData | |
Fields  | |
Instances
| Show ClientReadReqData Source # | |
Defined in Raft.NodeState Methods showsPrec :: Int -> ClientReadReqData -> ShowS # show :: ClientReadReqData -> String # showList :: [ClientReadReqData] -> ShowS #  | |
type ClientReadReqs = Map Int (ClientReadReqData, Int) Source #
The type mapping the number of the read request serviced to the id of the client that issued it and the number of success responses from followers confirming the leadership of the current leader
type ClientWriteReqCache = Map ClientId (SerialNum, Maybe Index) Source #
The type mapping client ids to the serial number of their latest write requests and the index of the entry if it has been replicated.
data LeaderState v Source #
Constructors
| LeaderState | |
Fields 
  | |
Instances
| Show v => Show (LeaderState v) Source # | |
Defined in Raft.NodeState Methods showsPrec :: Int -> LeaderState v -> ShowS # show :: LeaderState v -> String # showList :: [LeaderState v] -> ShowS #  | |
setLastLogEntry :: NodeState s v -> Entries v -> NodeState s v Source #
Update the last log entry in the node's log
getLastLogEntry :: NodeState ns v -> LastLogEntry v Source #
Get the last applied index and the commit index of the last log entry in the node's log
getLastLogEntryIndex :: NodeState ns v -> Index Source #
getCommitIndex :: NodeState ns v -> Index Source #
getLastAppliedAndCommitIndex :: NodeState ns v -> (Index, Index) Source #
Get the index of highest log entry applied to state machine and the index of highest log entry known to be committed
isFollower :: NodeState s v -> Bool Source #
Check if node is in a follower state
isCandidate :: NodeState s v -> Bool Source #
Check if node is in a candidate state