Documentation ¶
Index ¶
- Constants
- func DPrintf(format string, a ...interface{}) (n int, err error)
- func Max(a, b int) int
- func Min(a, b int) int
- type AppendEntriesArgs
- type AppendEntriesReply
- type ApplyMsg
- type InstallSnapshotArgs
- type InstallSnapshotReply
- type LogEntry
- type Persister
- func (ps *Persister) Copy() *Persister
- func (ps *Persister) RaftStateSize() int
- func (ps *Persister) ReadRaftState() []byte
- func (ps *Persister) ReadSnapshot() []byte
- func (ps *Persister) SaveRaftState(state []byte)
- func (ps *Persister) SaveSnapshot(snapshot []byte)
- func (ps *Persister) SaveStateAndSnapshot(state []byte, snapshot []byte)
- func (ps *Persister) SnapshotSize() int
- type Raft
- func (rf *Raft) AppendEntries(args AppendEntriesArgs, reply *AppendEntriesReply)
- func (rf *Raft) Commit()
- func (rf *Raft) FSM()
- func (rf *Raft) GetPerisistSize() int
- func (rf *Raft) GetState() (int, bool)
- func (rf *Raft) InstallSnapshot(args InstallSnapshotArgs, reply *InstallSnapshotReply)
- func (rf *Raft) Kill()
- func (rf *Raft) RequestVote(args RequestVoteArgs, reply *RequestVoteReply)
- func (rf *Raft) Start(command interface{}) (int, int, bool)
- func (rf *Raft) StartSnapshot(snapshot []byte, index int)
- type RequestVoteArgs
- type RequestVoteReply
- type State
Constants ¶
View Source
const ( AppendEntriesInterval = 50 * time.Millisecond HeartBeatInterval = 50 * time.Millisecond ChanSize = 1000 )
View Source
const Debug = 1
Debugging
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AppendEntriesArgs ¶
type AppendEntriesArgs struct { Term int LeaderId int PrevLogIndex int PrevLogTerm int Entries []LogEntry LeaderCommit int }
AppendEntries RPC
type AppendEntriesReply ¶
type InstallSnapshotArgs ¶
type InstallSnapshotArgs struct { Term int LeaderId int LastIncludeIndex int LastIncludeTerm int Data []byte }
InstallSnapShot RPC
type InstallSnapshotReply ¶
type InstallSnapshotReply struct {
Term int
}
type Persister ¶
type Persister struct {
// contains filtered or unexported fields
}
func MakePersister ¶
func MakePersister() *Persister
func (*Persister) RaftStateSize ¶
func (*Persister) ReadRaftState ¶
func (*Persister) ReadSnapshot ¶
func (*Persister) SaveRaftState ¶
func (*Persister) SaveSnapshot ¶
func (*Persister) SaveStateAndSnapshot ¶
Save both Raft state and K/V snapshot as a single atomic action, to help avoid them getting out of sync.
func (*Persister) SnapshotSize ¶
type Raft ¶
type Raft struct { // all CommitIndex int LastApplied int // contains filtered or unexported fields }
func (*Raft) AppendEntries ¶
func (rf *Raft) AppendEntries(args AppendEntriesArgs, reply *AppendEntriesReply)
func (*Raft) GetPerisistSize ¶
func (*Raft) InstallSnapshot ¶
func (rf *Raft) InstallSnapshot(args InstallSnapshotArgs, reply *InstallSnapshotReply)
func (*Raft) RequestVote ¶
func (rf *Raft) RequestVote(args RequestVoteArgs, reply *RequestVoteReply)
func (*Raft) StartSnapshot ¶
type RequestVoteArgs ¶
RequestVote RPC
type RequestVoteReply ¶
Click to show internal directories.
Click to hide internal directories.