Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AppendEntriesRPC ¶
type AppendEntriesRPC struct { Term uint64 `json:"term"` // the leader's term LeaderID string `json:"leader_id"` // the leader's ID (this allows followers to redirect clients) PrevLogIndex uint64 `json:"prev_log_index"` // the index of the log entry immediately preceding new logs PrevLogTerm uint64 `json:"prev_log_term"` // the term of PrevLogIndex Logs []Log `json:"logs"` // the log entries to store CommitIndex uint64 `json:"commit_index"` // the leader's commit index }
AppendEntriesRPC defines an RPC method used to handle a leader attempting to replicate log entries. It is also used as a heartbeat mechanism.
type JSONLogDecoder ¶
type JSONLogDecoder struct{}
JSONLogDecoder provides log JSON deserialization. It implements the LogDecoder interface.
type JSONLogEncoder ¶
type JSONLogEncoder struct{}
JSONLogEncoder provides log JSON serialization. It implements the LogEncoder interface.
type Log ¶
type Log struct { Index uint64 `json:"index"` Term uint64 `json:"term"` Command []byte `json:"command"` }
Log represents a command to execute in a state machine. Each log contains a monotonically increasing index and a term for when the log entry was received by a leader.
Contract: If two logs contain a log entry with the same index and term, then the logs are identical in all entries up through the given index.
type LogDecoder ¶
LogDecoder describes an interface that is able to decode an arbitrary series of bytes into a log.
type LogEncoder ¶
LogEncoder describes an interface that is able to encode a log into an arbitrary series of bytes.
type RequestVoteRPC ¶
type RequestVoteRPC struct { Term uint64 `json:"term"` // the candidate's term CandidateID string `json:"candidate_id"` // the candidate requesting a vote LastLogIndex uint64 `json:"last_log_index"` // the index of the candidate's last log entry LastLogTerm uint64 `json:"last_log_term"` // the term of the candidate's last log entry }
RequestVoteRPC defines an RPC method used to handle requesting and gathering Raft votes.