libraft-0.1.1.0: Raft consensus algorithm

Safe HaskellNone
LanguageHaskell2010

Raft

Contents

Synopsis

State machine type class

class RSMP sm v | sm -> v where Source #

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.

Associated Types

data RSMPError sm v Source #

type RSMPCtx sm v = ctx | ctx -> sm v Source #

Methods

applyCmdRSMP :: RSMPCtx sm v -> sm -> v -> Either (RSMPError sm v) sm Source #

class (Monad m, RSMP sm v) => RSM sm v m | m sm -> v where Source #

Methods

validateCmd :: v -> m (Either (RSMPError sm v) ()) Source #

askRSMPCtx :: m (RSMPCtx sm v) Source #

Networking type classes

class RaftSendRPC m v where Source #

Interface for nodes to send messages to one another. E.g. Control.Concurrent.Chan, Network.Socket, etc.

Methods

sendRPC :: NodeId -> RPCMessage v -> m () Source #

Instances
(MonadIO m, MonadConc m, Serialize v, Show v) => RaftSendRPC (RaftSocketT v m) v Source # 
Instance details

Defined in Examples.Raft.Socket.Node

Methods

sendRPC :: NodeId -> RPCMessage v -> RaftSocketT v m () Source #

class Show (RaftRecvRPCError m v) => RaftRecvRPC m v where Source #

Interface for nodes to receive messages from one another

Associated Types

type RaftRecvRPCError m v Source #

Instances
(MonadIO m, MonadConc m, Show v) => RaftRecvRPC (RaftSocketT v m) v Source # 
Instance details

Defined in Examples.Raft.Socket.Node

Associated Types

type RaftRecvRPCError (RaftSocketT v m) v :: Type Source #

class RaftSendClient m sm where Source #

Interface for Raft nodes to send messages to clients

Methods

sendClient :: ClientId -> ClientResponse sm -> m () Source #

Instances
(MonadIO m, MonadConc m, Serialize sm) => RaftSendClient (RaftSocketT v m) sm Source # 
Instance details

Defined in Examples.Raft.Socket.Node

class Show (RaftRecvClientError m v) => RaftRecvClient m v where Source #

Interface for Raft nodes to receive messages from clients

Associated Types

type RaftRecvClientError m v Source #

Instances
(MonadIO m, MonadConc m, Serialize v) => RaftRecvClient (RaftSocketT v m) v Source # 
Instance details

Defined in Examples.Raft.Socket.Node

Associated Types

type RaftRecvClientError (RaftSocketT v m) v :: Type Source #

type EventChan m v = TChan (STM m) (Event v) Source #

data RaftEnv v m Source #

The raft server environment composed of the concurrent variables used in the effectful raft layer.

runRaftNode Source #

Arguments

:: (Show v, Show sm, Show (Action sm v), MonadIO m, MonadConc m, MonadFail m, RSM sm v m, Show (RSMPError sm v), RaftSendRPC m v, RaftRecvRPC m v, RaftSendClient m sm, RaftRecvClient m v, RaftLog m v, RaftLogExceptions m, RaftPersist m, Exception (RaftPersistError m)) 
=> NodeConfig

Node configuration

-> LogDest

Logs destination

-> Int

Timer seed

-> sm

Initial state machine state

-> m () 

Run timers, RPC and client request handlers and start event loop. It should run forever

runRaftT :: MonadConc m => RaftNodeState -> RaftEnv v m -> RaftT v m () -> m () Source #

handleEventLoop :: forall sm v m. (Show v, Show sm, Show (Action sm v), MonadIO m, MonadConc m, MonadFail m, RSM sm v m, Show (RSMPError sm v), RaftPersist m, RaftSendRPC m v, RaftSendClient m sm, RaftLog m v, RaftLogExceptions m, RaftPersist m, Exception (RaftPersistError m)) => sm -> RaftT v m () Source #

Client data types

data ClientRequest v Source #

Representation of a client request coupled with the client id

Constructors

ClientRequest ClientId (ClientReq v) 
Instances
Show v => Show (ClientRequest v) Source # 
Instance details

Defined in Raft.Client

Generic (ClientRequest v) Source # 
Instance details

Defined in Raft.Client

Associated Types

type Rep (ClientRequest v) :: Type -> Type #

Serialize v => Serialize (ClientRequest v) Source # 
Instance details

Defined in Raft.Client

type Rep (ClientRequest v) Source # 
Instance details

Defined in Raft.Client

type Rep (ClientRequest v) = D1 (MetaData "ClientRequest" "Raft.Client" "libraft-0.1.1.0-8nwazCMBvi7EUIW9UIbZhF" False) (C1 (MetaCons "ClientRequest" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 ClientId) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (ClientReq v))))

data ClientReq v Source #

Representation of a client request

Constructors

ClientReadReq

Request the latest state of the state machine

ClientWriteReq v

Write a command

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

Defined in Raft.Client

Generic (ClientReq v) Source # 
Instance details

Defined in Raft.Client

Associated Types

type Rep (ClientReq v) :: Type -> Type #

Methods

from :: ClientReq v -> Rep (ClientReq v) x #

to :: Rep (ClientReq v) x -> ClientReq v #

Serialize v => Serialize (ClientReq v) Source # 
Instance details

Defined in Raft.Client

Methods

put :: Putter (ClientReq v) #

get :: Get (ClientReq v) #

type Rep (ClientReq v) Source # 
Instance details

Defined in Raft.Client

type Rep (ClientReq v) = D1 (MetaData "ClientReq" "Raft.Client" "libraft-0.1.1.0-8nwazCMBvi7EUIW9UIbZhF" False) (C1 (MetaCons "ClientReadReq" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "ClientWriteReq" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 v)))

data ClientResponse s Source #

Representation of a client response

Constructors

ClientReadResponse (ClientReadResp s)

Respond with the latest state of the state machine.

ClientWriteResponse ClientWriteResp

Respond with the index of the entry appended to the log

ClientRedirectResponse ClientRedirResp

Respond with the node id of the current leader

Instances
Show s => Show (ClientResponse s) Source # 
Instance details

Defined in Raft.Client

Generic (ClientResponse s) Source # 
Instance details

Defined in Raft.Client

Associated Types

type Rep (ClientResponse s) :: Type -> Type #

Serialize s => Serialize (ClientResponse s) Source # 
Instance details

Defined in Raft.Client

type Rep (ClientResponse s) Source # 
Instance details

Defined in Raft.Client

newtype ClientReadResp s Source #

Representation of a read response to a client The s stands for the "current" state of the state machine

Constructors

ClientReadResp s 
Instances
Show s => Show (ClientReadResp s) Source # 
Instance details

Defined in Raft.Client

Generic (ClientReadResp s) Source # 
Instance details

Defined in Raft.Client

Associated Types

type Rep (ClientReadResp s) :: Type -> Type #

Serialize s => Serialize (ClientReadResp s) Source # 
Instance details

Defined in Raft.Client

type Rep (ClientReadResp s) Source # 
Instance details

Defined in Raft.Client

type Rep (ClientReadResp s) = D1 (MetaData "ClientReadResp" "Raft.Client" "libraft-0.1.1.0-8nwazCMBvi7EUIW9UIbZhF" True) (C1 (MetaCons "ClientReadResp" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 s)))

data ClientWriteResp Source #

Representation of a write response to a client

Constructors

ClientWriteResp Index

Index of the entry appended to the log due to the previous client request

Instances
Show ClientWriteResp Source # 
Instance details

Defined in Raft.Client

Generic ClientWriteResp Source # 
Instance details

Defined in Raft.Client

Associated Types

type Rep ClientWriteResp :: Type -> Type #

Serialize ClientWriteResp Source # 
Instance details

Defined in Raft.Client

type Rep ClientWriteResp Source # 
Instance details

Defined in Raft.Client

type Rep ClientWriteResp = D1 (MetaData "ClientWriteResp" "Raft.Client" "libraft-0.1.1.0-8nwazCMBvi7EUIW9UIbZhF" False) (C1 (MetaCons "ClientWriteResp" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Index)))

data ClientRedirResp Source #

Representation of a redirect response to a client

Instances
Show ClientRedirResp Source # 
Instance details

Defined in Raft.Client

Generic ClientRedirResp Source # 
Instance details

Defined in Raft.Client

Associated Types

type Rep ClientRedirResp :: Type -> Type #

Serialize ClientRedirResp Source # 
Instance details

Defined in Raft.Client

type Rep ClientRedirResp Source # 
Instance details

Defined in Raft.Client

type Rep ClientRedirResp = D1 (MetaData "ClientRedirResp" "Raft.Client" "libraft-0.1.1.0-8nwazCMBvi7EUIW9UIbZhF" False) (C1 (MetaCons "ClientRedirResp" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 CurrentLeader)))

Configuration

data NodeConfig Source #

Configuration of a node in the cluster

Constructors

NodeConfig 

Fields

Instances
Show NodeConfig Source # 
Instance details

Defined in Raft.Config

Events

data Event v Source #

Representation of events a raft node can send and receive

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

Defined in Raft.Event

Methods

showsPrec :: Int -> Event v -> ShowS #

show :: Event v -> String #

showList :: [Event v] -> ShowS #

data Timeout Source #

Representation of timeouts

Constructors

ElectionTimeout

Timeout after which a follower will become candidate

HeartbeatTimeout

Timeout after which a leader will send AppendEntries RPC to all peers

Instances
Show Timeout Source # 
Instance details

Defined in Raft.Event

data MessageEvent v Source #

Representation of message events to a node

Constructors

RPCMessageEvent (RPCMessage v)

Incoming event from a peer

ClientRequestEvent (ClientRequest v)

Incoming event from a client

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

Defined in Raft.Event

Generic (MessageEvent v) Source # 
Instance details

Defined in Raft.Event

Associated Types

type Rep (MessageEvent v) :: Type -> Type #

Methods

from :: MessageEvent v -> Rep (MessageEvent v) x #

to :: Rep (MessageEvent v) x -> MessageEvent v #

Serialize v => Serialize (MessageEvent v) Source # 
Instance details

Defined in Raft.Event

type Rep (MessageEvent v) Source # 
Instance details

Defined in Raft.Event

type Rep (MessageEvent v) = D1 (MetaData "MessageEvent" "Raft.Event" "libraft-0.1.1.0-8nwazCMBvi7EUIW9UIbZhF" False) (C1 (MetaCons "RPCMessageEvent" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (RPCMessage v))) :+: C1 (MetaCons "ClientRequestEvent" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (ClientRequest v))))

Log

data Entry v Source #

Representation of an entry in the replicated log

Constructors

Entry 

Fields

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

Defined in Raft.Log

Methods

showsPrec :: Int -> Entry v -> ShowS #

show :: Entry v -> String #

showList :: [Entry v] -> ShowS #

Generic (Entry v) Source # 
Instance details

Defined in Raft.Log

Associated Types

type Rep (Entry v) :: Type -> Type #

Methods

from :: Entry v -> Rep (Entry v) x #

to :: Rep (Entry v) x -> Entry v #

Serialize v => Serialize (Entry v) Source # 
Instance details

Defined in Raft.Log

Methods

put :: Putter (Entry v) #

get :: Get (Entry v) #

type Rep (Entry v) Source # 
Instance details

Defined in Raft.Log

type Entries v = Seq (Entry v) Source #

class Monad m => RaftWriteLog m v where Source #

Provides an interface for nodes to write log entries to storage.

Associated Types

type RaftWriteLogError m Source #

Methods

writeLogEntries :: Exception (RaftWriteLogError m) => Entries v -> m (Either (RaftWriteLogError m) ()) Source #

Write the given log entries to storage

data DeleteSuccess v Source #

Constructors

DeleteSuccess 

class Monad m => RaftDeleteLog m v where Source #

Provides an interface for nodes to delete log entries from storage.

Associated Types

type RaftDeleteLogError m Source #

Methods

deleteLogEntriesFrom :: Exception (RaftDeleteLogError m) => Index -> m (Either (RaftDeleteLogError m) (DeleteSuccess v)) Source #

Delete log entries from a given index; e.g. 'deleteLogEntriesFrom 7' should delete every log entry with an index >= 7.

class Monad m => RaftReadLog m v where Source #

Provides an interface for nodes to read log entries from storage.

Minimal complete definition

readLogEntry, readLastLogEntry

Associated Types

type RaftReadLogError m Source #

Methods

readLogEntry :: Exception (RaftReadLogError m) => Index -> m (Either (RaftReadLogError m) (Maybe (Entry v))) Source #

Read the log at a given index

readLogEntriesFrom :: Exception (RaftReadLogError m) => Index -> m (Either (RaftReadLogError m) (Entries v)) Source #

Read log entries from a specific index onwards, including the specific index

readLastLogEntry :: Exception (RaftReadLogError m) => m (Either (RaftReadLogError m) (Maybe (Entry v))) Source #

Read the last log entry in the log

readLogEntriesFrom :: Exception (RaftReadLogError m) => Index -> m (Either (RaftReadLogError m) (Entries v)) Source #

Read log entries from a specific index onwards, including the specific index

data RaftLogError m Source #

Representation of possible errors that come from reading, writing or deleting logs from the persistent storage

Logging

data LogDest Source #

Representation of the logs' destination

data Severity Source #

Representation of the severity of the logs

Constructors

Info 
Debug 
Critical 
Instances
Show Severity Source # 
Instance details

Defined in Raft.Logging

Raft node states

data Mode Source #

Constructors

Follower 
Candidate 
Leader 
Instances
Show Mode Source # 
Instance details

Defined in Raft.NodeState

Methods

showsPrec :: Int -> Mode -> ShowS #

show :: Mode -> String #

showList :: [Mode] -> ShowS #

data RaftNodeState where Source #

Existential type hiding the internal node state

Constructors

RaftNodeState 

Fields

Instances
Show RaftNodeState Source # 
Instance details

Defined in Raft.NodeState

data NodeState (a :: Mode) where Source #

The volatile state of a Raft Node

Instances
Show (NodeState v) Source # 
Instance details

Defined in Raft.NodeState

data CurrentLeader Source #

Representation of the current leader in the cluster. The system is considered to be unavailable if there is no leader

Instances
Eq CurrentLeader Source # 
Instance details

Defined in Raft.NodeState

Show CurrentLeader Source # 
Instance details

Defined in Raft.NodeState

Generic CurrentLeader Source # 
Instance details

Defined in Raft.NodeState

Associated Types

type Rep CurrentLeader :: Type -> Type #

Serialize CurrentLeader Source # 
Instance details

Defined in Raft.NodeState

type Rep CurrentLeader Source # 
Instance details

Defined in Raft.NodeState

type Rep CurrentLeader = D1 (MetaData "CurrentLeader" "Raft.NodeState" "libraft-0.1.1.0-8nwazCMBvi7EUIW9UIbZhF" False) (C1 (MetaCons "CurrentLeader" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 LeaderId)) :+: C1 (MetaCons "NoLeader" PrefixI False) (U1 :: Type -> Type))

data FollowerState Source #

Constructors

FollowerState 

Fields

Instances
Show FollowerState Source # 
Instance details

Defined in Raft.NodeState

data CandidateState Source #

Constructors

CandidateState 

Fields

Instances
Show CandidateState Source # 
Instance details

Defined in Raft.NodeState

data LeaderState Source #

Constructors

LeaderState 

Fields

Instances
Show LeaderState Source # 
Instance details

Defined in Raft.NodeState

initRaftNodeState :: RaftNodeState Source #

A node in Raft begins as a follower

isFollower :: NodeState s -> Bool Source #

Check if node is in a follower state

isCandidate :: NodeState s -> Bool Source #

Check if node is in a candidate state

isLeader :: NodeState s -> Bool Source #

Check if node is in a leader state

setLastLogEntryData :: NodeState ns -> Entries v -> NodeState ns Source #

Update the last log entry in the node's log

getLastLogEntryData :: NodeState ns -> (Index, Term) Source #

Get the last applied index and the commit index of the last log entry in the node's log

getLastAppliedAndCommitIndex :: NodeState ns -> (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

Persistent state

data PersistentState Source #

Persistent state that all Raft nodes maintain, regardless of node state.

Constructors

PersistentState 

Fields

Instances
Show PersistentState Source # 
Instance details

Defined in Raft.Persistent

Generic PersistentState Source # 
Instance details

Defined in Raft.Persistent

Associated Types

type Rep PersistentState :: Type -> Type #

Serialize PersistentState Source # 
Instance details

Defined in Raft.Persistent

MonadState PersistentState (TransitionM sm v) Source # 
Instance details

Defined in Raft.Monad

RaftLogger (RWS (TransitionEnv sm) [Action sm v] PersistentState) Source # 
Instance details

Defined in Raft.Monad

type Rep PersistentState Source # 
Instance details

Defined in Raft.Persistent

type Rep PersistentState = D1 (MetaData "PersistentState" "Raft.Persistent" "libraft-0.1.1.0-8nwazCMBvi7EUIW9UIbZhF" False) (C1 (MetaCons "PersistentState" PrefixI True) (S1 (MetaSel (Just "currentTerm") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Term) :*: S1 (MetaSel (Just "votedFor") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe NodeId))))

initPersistentState :: PersistentState Source #

A node initiates its persistent state with term 0 and with its vote blank

Basic types

type NodeId = ByteString Source #

Unique identifier of a Raft node

newtype ClientId Source #

Unique identifier of a client

Constructors

ClientId NodeId 
Instances
Eq ClientId Source # 
Instance details

Defined in Raft.Types

Ord ClientId Source # 
Instance details

Defined in Raft.Types

Show ClientId Source # 
Instance details

Defined in Raft.Types

Generic ClientId Source # 
Instance details

Defined in Raft.Types

Associated Types

type Rep ClientId :: Type -> Type #

Methods

from :: ClientId -> Rep ClientId x #

to :: Rep ClientId x -> ClientId #

Serialize ClientId Source # 
Instance details

Defined in Raft.Types

type Rep ClientId Source # 
Instance details

Defined in Raft.Types

type Rep ClientId = D1 (MetaData "ClientId" "Raft.Types" "libraft-0.1.1.0-8nwazCMBvi7EUIW9UIbZhF" True) (C1 (MetaCons "ClientId" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 NodeId)))

newtype LeaderId Source #

Unique identifier of a leader

Constructors

LeaderId 

Fields

Instances
Eq LeaderId Source # 
Instance details

Defined in Raft.Types

Show LeaderId Source # 
Instance details

Defined in Raft.Types

Generic LeaderId Source # 
Instance details

Defined in Raft.Types

Associated Types

type Rep LeaderId :: Type -> Type #

Methods

from :: LeaderId -> Rep LeaderId x #

to :: Rep LeaderId x -> LeaderId #

Serialize LeaderId Source # 
Instance details

Defined in Raft.Types

type Rep LeaderId Source # 
Instance details

Defined in Raft.Types

type Rep LeaderId = D1 (MetaData "LeaderId" "Raft.Types" "libraft-0.1.1.0-8nwazCMBvi7EUIW9UIbZhF" True) (C1 (MetaCons "LeaderId" PrefixI True) (S1 (MetaSel (Just "unLeaderId") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 NodeId)))

newtype Term Source #

Representation of monotonic election terms

Constructors

Term Natural 
Instances
Enum Term Source # 
Instance details

Defined in Raft.Types

Methods

succ :: Term -> Term #

pred :: Term -> Term #

toEnum :: Int -> Term #

fromEnum :: Term -> Int #

enumFrom :: Term -> [Term] #

enumFromThen :: Term -> Term -> [Term] #

enumFromTo :: Term -> Term -> [Term] #

enumFromThenTo :: Term -> Term -> Term -> [Term] #

Eq Term Source # 
Instance details

Defined in Raft.Types

Methods

(==) :: Term -> Term -> Bool #

(/=) :: Term -> Term -> Bool #

Ord Term Source # 
Instance details

Defined in Raft.Types

Methods

compare :: Term -> Term -> Ordering #

(<) :: Term -> Term -> Bool #

(<=) :: Term -> Term -> Bool #

(>) :: Term -> Term -> Bool #

(>=) :: Term -> Term -> Bool #

max :: Term -> Term -> Term #

min :: Term -> Term -> Term #

Show Term Source # 
Instance details

Defined in Raft.Types

Methods

showsPrec :: Int -> Term -> ShowS #

show :: Term -> String #

showList :: [Term] -> ShowS #

Generic Term Source # 
Instance details

Defined in Raft.Types

Associated Types

type Rep Term :: Type -> Type #

Methods

from :: Term -> Rep Term x #

to :: Rep Term x -> Term #

Serialize Term Source # 
Instance details

Defined in Raft.Types

Methods

put :: Putter Term #

get :: Get Term #

type Rep Term Source # 
Instance details

Defined in Raft.Types

type Rep Term = D1 (MetaData "Term" "Raft.Types" "libraft-0.1.1.0-8nwazCMBvi7EUIW9UIbZhF" True) (C1 (MetaCons "Term" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Natural)))

newtype Index Source #

Representation of monotonic indices

Constructors

Index Natural 
Instances
Enum Index Source # 
Instance details

Defined in Raft.Types

Eq Index Source # 
Instance details

Defined in Raft.Types

Methods

(==) :: Index -> Index -> Bool #

(/=) :: Index -> Index -> Bool #

Integral Index Source # 
Instance details

Defined in Raft.Types

Num Index Source # 
Instance details

Defined in Raft.Types

Ord Index Source # 
Instance details

Defined in Raft.Types

Methods

compare :: Index -> Index -> Ordering #

(<) :: Index -> Index -> Bool #

(<=) :: Index -> Index -> Bool #

(>) :: Index -> Index -> Bool #

(>=) :: Index -> Index -> Bool #

max :: Index -> Index -> Index #

min :: Index -> Index -> Index #

Real Index Source # 
Instance details

Defined in Raft.Types

Methods

toRational :: Index -> Rational #

Show Index Source # 
Instance details

Defined in Raft.Types

Methods

showsPrec :: Int -> Index -> ShowS #

show :: Index -> String #

showList :: [Index] -> ShowS #

Generic Index Source # 
Instance details

Defined in Raft.Types

Associated Types

type Rep Index :: Type -> Type #

Methods

from :: Index -> Rep Index x #

to :: Rep Index x -> Index #

Serialize Index Source # 
Instance details

Defined in Raft.Types

Methods

put :: Putter Index #

get :: Get Index #

type Rep Index Source # 
Instance details

Defined in Raft.Types

type Rep Index = D1 (MetaData "Index" "Raft.Types" "libraft-0.1.1.0-8nwazCMBvi7EUIW9UIbZhF" True) (C1 (MetaCons "Index" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Natural)))

term0 :: Term Source #

Initial term. Terms start at 0

index0 :: Index Source #

Initial index. Indeces start at 0

RPC

data RPC v Source #

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

Defined in Raft.RPC

Methods

showsPrec :: Int -> RPC v -> ShowS #

show :: RPC v -> String #

showList :: [RPC v] -> ShowS #

Generic (RPC v) Source # 
Instance details

Defined in Raft.RPC

Associated Types

type Rep (RPC v) :: Type -> Type #

Methods

from :: RPC v -> Rep (RPC v) x #

to :: Rep (RPC v) x -> RPC v #

Serialize v => Serialize (RPC v) Source # 
Instance details

Defined in Raft.RPC

Methods

put :: Putter (RPC v) #

get :: Get (RPC v) #

type Rep (RPC v) Source # 
Instance details

Defined in Raft.RPC

class RPCType a v where Source #

Methods

toRPC :: a -> RPC v Source #

Instances
RPCType RequestVoteResponse v Source # 
Instance details

Defined in Raft.RPC

RPCType RequestVote v Source # 
Instance details

Defined in Raft.RPC

Methods

toRPC :: RequestVote -> RPC v Source #

RPCType AppendEntriesResponse v Source # 
Instance details

Defined in Raft.RPC

RPCType (AppendEntries v) v Source # 
Instance details

Defined in Raft.RPC

Methods

toRPC :: AppendEntries v -> RPC v Source #

data RPCMessage v Source #

Representation of a message sent between nodes

Constructors

RPCMessage 

Fields

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

Defined in Raft.RPC

Generic (RPCMessage v) Source # 
Instance details

Defined in Raft.RPC

Associated Types

type Rep (RPCMessage v) :: Type -> Type #

Methods

from :: RPCMessage v -> Rep (RPCMessage v) x #

to :: Rep (RPCMessage v) x -> RPCMessage v #

Serialize v => Serialize (RPCMessage v) Source # 
Instance details

Defined in Raft.RPC

Methods

put :: Putter (RPCMessage v) #

get :: Get (RPCMessage v) #

type Rep (RPCMessage v) Source # 
Instance details

Defined in Raft.RPC

type Rep (RPCMessage v) = D1 (MetaData "RPCMessage" "Raft.RPC" "libraft-0.1.1.0-8nwazCMBvi7EUIW9UIbZhF" False) (C1 (MetaCons "RPCMessage" PrefixI True) (S1 (MetaSel (Just "sender") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 NodeId) :*: S1 (MetaSel (Just "rpc") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (RPC v))))

data AppendEntries v Source #

Representation of a message sent from a leader to its peers

Constructors

AppendEntries 

Fields

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

Defined in Raft.RPC

Generic (AppendEntries v) Source # 
Instance details

Defined in Raft.RPC

Associated Types

type Rep (AppendEntries v) :: Type -> Type #

Serialize v => Serialize (AppendEntries v) Source # 
Instance details

Defined in Raft.RPC

RPCType (AppendEntries v) v Source # 
Instance details

Defined in Raft.RPC

Methods

toRPC :: AppendEntries v -> RPC v Source #

type Rep (AppendEntries v) Source # 
Instance details

Defined in Raft.RPC

data AppendEntriesResponse Source #

Representation of the response from a follower to an AppendEntries message

Constructors

AppendEntriesResponse 

Fields

data RequestVote Source #

Representation of the message sent by candidates to their peers to request their vote

Constructors

RequestVote 

Fields

Instances
Show RequestVote Source # 
Instance details

Defined in Raft.RPC

Generic RequestVote Source # 
Instance details

Defined in Raft.RPC

Associated Types

type Rep RequestVote :: Type -> Type #

Serialize RequestVote Source # 
Instance details

Defined in Raft.RPC

RPCType RequestVote v Source # 
Instance details

Defined in Raft.RPC

Methods

toRPC :: RequestVote -> RPC v Source #

type Rep RequestVote Source # 
Instance details

Defined in Raft.RPC

data RequestVoteResponse Source #

Representation of a response to a RequestVote message

Constructors

RequestVoteResponse 

Fields

Instances
Show RequestVoteResponse Source # 
Instance details

Defined in Raft.RPC

Generic RequestVoteResponse Source # 
Instance details

Defined in Raft.RPC

Associated Types

type Rep RequestVoteResponse :: Type -> Type #

Serialize RequestVoteResponse Source # 
Instance details

Defined in Raft.RPC

RPCType RequestVoteResponse v Source # 
Instance details

Defined in Raft.RPC

type Rep RequestVoteResponse Source # 
Instance details

Defined in Raft.RPC

type Rep RequestVoteResponse = D1 (MetaData "RequestVoteResponse" "Raft.RPC" "libraft-0.1.1.0-8nwazCMBvi7EUIW9UIbZhF" False) (C1 (MetaCons "RequestVoteResponse" PrefixI True) (S1 (MetaSel (Just "rvrTerm") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Term) :*: S1 (MetaSel (Just "rvrVoteGranted") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Bool)))

data AppendEntriesData v Source #

The data used to construct an AppendEntries value, snapshotted from the node state at the time the AppendEntries val should be created.

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

Defined in Raft.RPC