Documentation ¶
Index ¶
- Constants
- type AppendEntriesArgs
- type AppendEntriesReply
- type Entry
- type Raft
- func (raft *Raft) AppendEntries(args AppendEntriesArgs, reply *AppendEntriesReply) error
- func (raft *Raft) Apply(command any) error
- func (raft *Raft) Down() error
- func (raft *Raft) GetInfo() RaftInfo
- func (raft *Raft) RequestVote(args RequestVoteArgs, reply *RequestVoteReply) error
- func (raft *Raft) Up() error
- type RaftInfo
- type RaftNode
- type RaftPeer
- type RaftSettings
- type RequestVoteArgs
- type RequestVoteReply
Constants ¶
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AppendEntriesArgs ¶
type AppendEntriesArgs struct { Term int LeaderId string PrevLogIndex int PrevLogTerm int Entries []Entry LeaderCommit int }
AppendEntries RPC args
type AppendEntriesReply ¶
AppendEntries RPC reply
type Raft ¶
type Raft struct {
// contains filtered or unexported fields
}
Local Raft instance state
func (*Raft) AppendEntries ¶
func (raft *Raft) AppendEntries(args AppendEntriesArgs, reply *AppendEntriesReply) error
AppendEntries RPC handler
func (*Raft) Apply ¶
Apply command to the local instance
Error is returned either if the instance is not Leader at the time or in case of any other error
func (*Raft) Down ¶
Shutdown local Raft instance
Idempotent. Returns nil if already stopped. Successful call indicates that the instance is gracefully shut down and can be started again
func (*Raft) RequestVote ¶
func (raft *Raft) RequestVote(args RequestVoteArgs, reply *RequestVoteReply) error
RequestVote RPC handler
type RaftNode ¶
Network topology info provider for local Raft instance
Implementation is expected to be thread-safe
type RaftPeer ¶
type RaftPeer interface { Id() string RequestVote(args RequestVoteArgs, reply *RequestVoteReply) error AppendEntries(args AppendEntriesArgs, reply *AppendEntriesReply) error }
Remote Raft instance
Implementation is expected to be thread-safe
type RaftSettings ¶
type RaftSettings interface { HeartbeatTimeout() time.Duration ElectionTimeout() time.Duration Majority(peers int) int }
Static-ish settings and configuration for local Raft instance
Implementation is expected to be thread-safe
type RequestVoteArgs ¶
RequestVote RPC args
type RequestVoteReply ¶
RequestVote RPC reply