raft

package module
v0.0.0-...-1c764cd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 1, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppendEntriesArgs

type AppendEntriesArgs struct {
	Term         int
	LeaderID     int
	PrevLogIndex int
	PrevLogTerm  int
	Entries      []LogEntry
	LeaderCommit int
}

type AppendEntriesReply

type AppendEntriesReply struct {
	// Your data here.
	Term    int
	Success bool
}

type ApplyMsg

type ApplyMsg struct {
	Index       int
	Command     interface{}
	UseSnapshot bool
	Snapshot    []byte
}

type LogEntry

type LogEntry struct {
	Term    int
	Command interface{}
}

type Raft

type Raft struct {
	Log []LogEntry
	// contains filtered or unexported fields
}

A Go object implementing a single Raft peer.

func Make

func Make(peers []*labrpc.ClientEnd, me int,
	persister *Persister, applyCh chan ApplyMsg) *Raft

func (*Raft) AppendEntries

func (rf *Raft) AppendEntries(args AppendEntriesArgs, reply *AppendEntriesReply)

func (*Raft) ApplyCommittedLogEntries

func (rf *Raft) ApplyCommittedLogEntries()

func (*Raft) GetState

func (rf *Raft) GetState() (int, bool)

return currentTerm and whether this server believes it is the leader.

func (*Raft) Kill

func (rf *Raft) Kill()

func (*Raft) RequestVote

func (rf *Raft) RequestVote(args RequestVoteArgs, reply *RequestVoteReply)

example RequestVote RPC handler.

func (*Raft) Start

func (rf *Raft) Start(command interface{}) (int, int, bool)

func (*Raft) TakeMin

func (rf *Raft) TakeMin(x1 int, x2 int) int

type RequestVoteArgs

type RequestVoteArgs struct {
	// Your data here.
	Term         int
	CandidateID  int
	LastLogIndex int
	LastLogTerm  int
}

example RequestVote RPC arguments structure.

type RequestVoteReply

type RequestVoteReply struct {
	// Your data here.
	Term        int
	VoteGranted bool
}

example RequestVote RPC reply structure.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL