raft

package
v0.0.0-...-00b922a Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Follower = iota
	Candidate
	Leader
)

Server Roles

Variables

This section is empty.

Functions

This section is empty.

Types

type AppendEntriesArgs

type AppendEntriesArgs struct {
	LeaderTerm int
	LeaderID   int
}

AppendEntriesArgs args for Append Entries RPC

type AppendEntriesReply

type AppendEntriesReply struct {
	Term int
}

AppendEntriesReply reply for Append Entries RPC

type ApplyMsg

type ApplyMsg struct {
	Index       int
	Command     interface{}
	UseSnapshot bool   // ignore for Assignment2; only used in Assignment3
	Snapshot    []byte // ignore for Assignment2; only used in Assignment3
}

ApplyMsg struct for Assignment 3

type Raft

type Raft struct {
	// contains filtered or unexported fields
}

Raft struct for Raft Node

func Make

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

Make for tester to make Raft Nodes

func (*Raft) AppendEntries

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

AppendEntries executes Append Entries RPC on Receiver

func (*Raft) GetState

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

GetState fetches state for tester

func (*Raft) Kill

func (rf *Raft) Kill()

Kill for removing debug log for dead nodes

func (*Raft) RequestVote

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

RequestVote executes Request Vote RPC on Receiver

func (*Raft) Start

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

Start for tester to Start

type RequestVoteArgs

type RequestVoteArgs struct {
	CandidateTerm int
	CandidateID   int
}

RequestVoteArgs args for Request Vote RPC

type RequestVoteReply

type RequestVoteReply struct {
	Term        int
	VoteGranted bool
}

RequestVoteReply reply for Request Vote RPC

Jump to

Keyboard shortcuts

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