Documentation
¶
Index ¶
- Constants
- func Start()
- type CandidateState
- type ChannelComms
- type Cluster
- type CommonState
- type Comms
- type Entry
- type FollowerState
- type ID
- type InMemoryLog
- func (l *InMemoryLog) Append(entry Entry) error
- func (l *InMemoryLog) Commit(index int) error
- func (l *InMemoryLog) GetLastApplied() int
- func (l *InMemoryLog) GetLastCommitted() int
- func (l *InMemoryLog) GetLastLogTermIndex() (term, index int)
- func (l *InMemoryLog) Read(index int) (entry *Entry, ok bool)
- func (l *InMemoryLog) TruncateTo(index int) error
- type LAN
- type LeaderState
- type RaftDriver
- type RaftFSM
- type RaftLog
- type RaftLogAppender
- type RaftLogCommitter
- type RaftLogReader
- type RaftLogTruncator
- type RaftNode
- type RealRaftFSM
- func (r *RealRaftFSM) BecomeCandidate()
- func (r *RealRaftFSM) BecomeFollower()
- func (r *RealRaftFSM) BecomeLeader()
- func (r *RealRaftFSM) CommitIndex() int
- func (r *RealRaftFSM) GetComms() Comms
- func (r *RealRaftFSM) GetCurrentTerm() int
- func (r *RealRaftFSM) Id() ID
- func (r *RealRaftFSM) LastAppliedIndex() int
- func (r *RealRaftFSM) Log() RaftLog
- func (r *RealRaftFSM) ReceiveAppendEntriesReply(msg *rpc.AppendEntriesReply)
- func (r *RealRaftFSM) ReceiveAppendEntriesRpc(msg *rpc.AppendEntriesReq)
- func (r *RealRaftFSM) ReceiveMsg(msg rpc.Message)
- func (r *RealRaftFSM) ReceiveVoteRequestRpc(msg *rpc.RequestVote)
- func (r *RealRaftFSM) ReceiveVotedFor(msg *rpc.VotedFor)
- func (r *RealRaftFSM) ReplicateToLog(data interface{}) error
- func (r *RealRaftFSM) Role() Role
- func (r *RealRaftFSM) Tick() int
- func (r *RealRaftFSM) VotedFor() ID
- type Role
- type Status
- type TCPNetworkComms
Constants ¶
View Source
const ( NoTimeOut = iota ElectionTimedOut HeartBeatTimeOut )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CandidateState ¶
type CandidateState struct { Majority int ElectionDeadline int ElectionTimeout int VotesReceived map[ID]bool }
func (*CandidateState) CountVote ¶
func (c *CandidateState) CountVote() int
func (*CandidateState) GotVoteFrom ¶
func (s *CandidateState) GotVoteFrom(id ID)
func (*CandidateState) HasElectionTimeout ¶
func (c *CandidateState) HasElectionTimeout(currentTick int) bool
func (*CandidateState) HasMajority ¶
func (s *CandidateState) HasMajority() bool
func (*CandidateState) ResetTime ¶
func (c *CandidateState) ResetTime(currentTick int)
func (*CandidateState) ResetVotes ¶
func (c *CandidateState) ResetVotes()
type ChannelComms ¶
type ChannelComms struct { SelfId ID // contains filtered or unexported fields }
func NewChannelComms ¶
func NewChannelComms(selfId ID, conns map[ID]chan rpc.Message) *ChannelComms
func (*ChannelComms) BroadcastRpc ¶
func (comms *ChannelComms) BroadcastRpc(ctx context.Context, msg rpc.Message)
func (*ChannelComms) Close ¶
func (comms *ChannelComms) Close()
func (*ChannelComms) Reply ¶
func (comms *ChannelComms) Reply() <-chan rpc.Message
func (*ChannelComms) Start ¶
func (comms *ChannelComms) Start()
type CommonState ¶
func (*CommonState) NextTerm ¶
func (s *CommonState) NextTerm()
type Comms ¶
type FollowerState ¶
func (*FollowerState) HasHeartBeatTimeout ¶
func (s *FollowerState) HasHeartBeatTimeout(currentTick int) bool
func (*FollowerState) ResetHeartBeatTimeout ¶
func (s *FollowerState) ResetHeartBeatTimeout(currentTick int)
type InMemoryLog ¶
type InMemoryLog struct { Entries []Entry LastApplied uint64 LastCommitted uint64 // contains filtered or unexported fields }
func (*InMemoryLog) Append ¶
func (l *InMemoryLog) Append(entry Entry) error
func (*InMemoryLog) Commit ¶
func (l *InMemoryLog) Commit(index int) error
func (*InMemoryLog) GetLastApplied ¶
func (l *InMemoryLog) GetLastApplied() int
func (*InMemoryLog) GetLastCommitted ¶
func (l *InMemoryLog) GetLastCommitted() int
func (*InMemoryLog) GetLastLogTermIndex ¶
func (l *InMemoryLog) GetLastLogTermIndex() (term, index int)
func (*InMemoryLog) TruncateTo ¶
func (l *InMemoryLog) TruncateTo(index int) error
type LAN ¶
type LAN struct {
// contains filtered or unexported fields
}
func CreateFullyConnected ¶
func (*LAN) GetConnection ¶
type LeaderState ¶
type LeaderState struct { NextIndices map[ID]int MatchIndices map[ID]int NextHeartBeatTime int HeartBeatTimeout int }
func (*LeaderState) Reset ¶
func (s *LeaderState) Reset()
func (*LeaderState) ResetNextHeartBeatTime ¶
func (s *LeaderState) ResetNextHeartBeatTime(currentTick int)
type RaftDriver ¶
type RaftDriver interface { Init(fsm RaftFSM, tickInterval time.Duration) Shutdown() <-chan struct{} Run(ctx context.Context) }
func NewTestDriver ¶
func NewTestDriver() RaftDriver
type RaftFSM ¶
type RaftLog ¶
type RaftLog interface { GetLastApplied() int GetLastCommitted() int GetLastLogTermIndex() (term, index int) RaftLogAppender RaftLogTruncator RaftLogReader RaftLogCommitter }
func NewInMemoryLog ¶
func NewInMemoryLog() RaftLog
type RaftLogAppender ¶
type RaftLogCommitter ¶
type RaftLogReader ¶
type RaftLogTruncator ¶
type RealRaftFSM ¶
type RealRaftFSM struct { CommonState LeaderState FollowerState CandidateState // contains filtered or unexported fields }
func (*RealRaftFSM) BecomeCandidate ¶
func (r *RealRaftFSM) BecomeCandidate()
func (*RealRaftFSM) BecomeFollower ¶
func (r *RealRaftFSM) BecomeFollower()
func (*RealRaftFSM) BecomeLeader ¶
func (r *RealRaftFSM) BecomeLeader()
func (*RealRaftFSM) CommitIndex ¶
func (r *RealRaftFSM) CommitIndex() int
func (*RealRaftFSM) GetComms ¶
func (r *RealRaftFSM) GetComms() Comms
func (*RealRaftFSM) GetCurrentTerm ¶
func (r *RealRaftFSM) GetCurrentTerm() int
func (*RealRaftFSM) Id ¶
func (r *RealRaftFSM) Id() ID
func (*RealRaftFSM) LastAppliedIndex ¶
func (r *RealRaftFSM) LastAppliedIndex() int
func (*RealRaftFSM) Log ¶
func (r *RealRaftFSM) Log() RaftLog
func (*RealRaftFSM) ReceiveAppendEntriesReply ¶
func (r *RealRaftFSM) ReceiveAppendEntriesReply(msg *rpc.AppendEntriesReply)
func (*RealRaftFSM) ReceiveAppendEntriesRpc ¶
func (r *RealRaftFSM) ReceiveAppendEntriesRpc(msg *rpc.AppendEntriesReq)
func (*RealRaftFSM) ReceiveMsg ¶
func (r *RealRaftFSM) ReceiveMsg(msg rpc.Message)
func (*RealRaftFSM) ReceiveVoteRequestRpc ¶
func (r *RealRaftFSM) ReceiveVoteRequestRpc(msg *rpc.RequestVote)
func (*RealRaftFSM) ReceiveVotedFor ¶
func (r *RealRaftFSM) ReceiveVotedFor(msg *rpc.VotedFor)
func (*RealRaftFSM) ReplicateToLog ¶
func (r *RealRaftFSM) ReplicateToLog(data interface{}) error
func (*RealRaftFSM) Role ¶
func (r *RealRaftFSM) Role() Role
func (*RealRaftFSM) Tick ¶
func (r *RealRaftFSM) Tick() int
func (*RealRaftFSM) VotedFor ¶
func (r *RealRaftFSM) VotedFor() ID
type TCPNetworkComms ¶
type TCPNetworkComms struct { }
Source Files
¶
Click to show internal directories.
Click to hide internal directories.