libraft-0.5.0.0: Raft consensus algorithm

Safe HaskellNone
LanguageHaskell2010

Raft.NodeState

Synopsis

Documentation

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 # 
Instance details

Defined in Raft.NodeState

Methods

showsPrec :: Int -> ResultState init v -> ShowS #

show :: ResultState init v -> String #

showList :: [ResultState init v] -> ShowS #

data RaftNodeState v where Source #

Existential type hiding the internal node state

Constructors

RaftNodeState 

Fields

Instances
Show v => Show (RaftNodeState v) Source # 
Instance details

Defined in Raft.NodeState

Monad m => MonadState (RaftNodeState v) (RaftT v m) Source # 
Instance details

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 #

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

Instances
Show v => Show (NodeState s v) Source # 
Instance details

Defined in Raft.NodeState

Methods

showsPrec :: Int -> NodeState s v -> ShowS #

show :: NodeState s v -> String #

showList :: [NodeState s v] -> ShowS #

data FollowerState v Source #

Constructors

FollowerState 

Fields

Instances
Show v => Show (FollowerState v) Source # 
Instance details

Defined in Raft.NodeState

data CandidateState v Source #

Constructors

CandidateState 

Fields

Instances
Show v => Show (CandidateState v) Source # 
Instance details

Defined in Raft.NodeState

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 # 
Instance details

Defined in Raft.NodeState

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

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

isLeader :: NodeState s v -> Bool Source #

Check if node is in a leader state