| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Raft.Monad
Synopsis
- class RSMP sm v | sm -> v where
- class (Monad m, RSMP sm v) => RSM sm v m | m sm -> v where
- validateCmd :: v -> m (Either (RSMPError sm v) ())
- askRSMPCtx :: m (RSMPCtx sm v)
- applyEntryRSM :: RSM sm v m => sm -> Entry v -> m (Either (RSMPError sm v) sm)
- tellAction :: Action sm v -> TransitionM sm v ()
- tellActions :: [Action sm v] -> TransitionM sm v ()
- data TransitionEnv sm = TransitionEnv {
- nodeConfig :: NodeConfig
- stateMachine :: sm
- nodeState :: RaftNodeState
- newtype TransitionM sm v a = TransitionM {
- unTransitionM :: RaftLoggerT (RWS (TransitionEnv sm) [Action sm v] PersistentState) a
- runTransitionM :: TransitionEnv sm -> PersistentState -> TransitionM sm v a -> ((a, [LogMsg]), PersistentState, [Action sm v])
- askNodeId :: TransitionM sm v NodeId
- type RPCHandler ns sm r v = RPCType r v => NodeState ns -> NodeId -> r -> TransitionM sm v (ResultState ns)
- type TimeoutHandler ns sm v = NodeState ns -> Timeout -> TransitionM sm v (ResultState ns)
- type ClientReqHandler ns sm v = NodeState ns -> ClientRequest v -> TransitionM sm v (ResultState ns)
- broadcast :: SendRPCAction v -> TransitionM sm v ()
- send :: NodeId -> SendRPCAction v -> TransitionM sm v ()
- resetElectionTimeout :: TransitionM sm v ()
- resetHeartbeatTimeout :: TransitionM sm v ()
- redirectClientToLeader :: ClientId -> CurrentLeader -> TransitionM sm v ()
- respondClientRead :: ClientId -> TransitionM sm v ()
- appendLogEntries :: Show v => Seq (Entry v) -> TransitionM sm v ()
- startElection :: Index -> Index -> (Index, Term) -> TransitionM sm v CandidateState
- logInfo :: Text -> TransitionM sm v ()
- logDebug :: Text -> TransitionM sm v ()
Documentation
class RSMP sm v | sm -> v where #
Interface to handle commands in the underlying state machine. Functional dependency permitting only a single state machine command to be defined to update the state machine.
Methods
applyCmdRSMP :: RSMPCtx sm v -> sm -> v -> Either (RSMPError sm v) sm #
tellAction :: Action sm v -> TransitionM sm v () #
tellActions :: [Action sm v] -> TransitionM sm v () #
data TransitionEnv sm #
Constructors
| TransitionEnv | |
Fields
| |
Instances
| MonadReader (TransitionEnv sm) (TransitionM sm v) # | |
Defined in Raft.Monad Methods ask :: TransitionM sm v (TransitionEnv sm) # local :: (TransitionEnv sm -> TransitionEnv sm) -> TransitionM sm v a -> TransitionM sm v a # reader :: (TransitionEnv sm -> a) -> TransitionM sm v a # | |
| RaftLogger (RWS (TransitionEnv sm) [Action sm v] PersistentState) # | |
Defined in Raft.Monad Methods loggerNodeId :: RWS (TransitionEnv sm) [Action sm v] PersistentState NodeId # loggerNodeState :: RWS (TransitionEnv sm) [Action sm v] PersistentState RaftNodeState # | |
newtype TransitionM sm v a #
Constructors
| TransitionM | |
Fields
| |
Instances
runTransitionM :: TransitionEnv sm -> PersistentState -> TransitionM sm v a -> ((a, [LogMsg]), PersistentState, [Action sm v]) #
askNodeId :: TransitionM sm v NodeId #
type RPCHandler ns sm r v = RPCType r v => NodeState ns -> NodeId -> r -> TransitionM sm v (ResultState ns) #
type TimeoutHandler ns sm v = NodeState ns -> Timeout -> TransitionM sm v (ResultState ns) #
type ClientReqHandler ns sm v = NodeState ns -> ClientRequest v -> TransitionM sm v (ResultState ns) #
broadcast :: SendRPCAction v -> TransitionM sm v () #
send :: NodeId -> SendRPCAction v -> TransitionM sm v () #
resetElectionTimeout :: TransitionM sm v () #
Resets the election timeout.
resetHeartbeatTimeout :: TransitionM sm v () #
redirectClientToLeader :: ClientId -> CurrentLeader -> TransitionM sm v () #
respondClientRead :: ClientId -> TransitionM sm v () #
appendLogEntries :: Show v => Seq (Entry v) -> TransitionM sm v () #
Arguments
| :: Index | |
| -> Index | |
| -> (Index, Term) | Last log entry data |
| -> TransitionM sm v CandidateState |
logInfo :: Text -> TransitionM sm v () #
logDebug :: Text -> TransitionM sm v () #