raft

package
v0.0.0-...-a5b6b36 Latest Latest
Warning

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

Go to latest
Published: May 11, 2017 License: MIT Imports: 17 Imported by: 1

Documentation

Index

Constants

View Source
const DumpRPCAppendEntries = false

Variables

This section is empty.

Functions

This section is empty.

Types

type AppendEntriesSession

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

func NewAppendEntriesSession

func NewAppendEntriesSession(me int, ctx context.Context, req *pb.AppendEntriesReq, res *pb.AppendEntriesRes) *AppendEntriesSession

type ApplyMsg

type ApplyMsg struct {
	Command     *pb.KVCommand
	UseSnapshot bool   // ignore for lab2; only used in lab3
	Snapshot    []byte // ignore for lab2; only used in lab3
}

type Raft

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

Raft A Go object implementing a single Raft peer.

func NewRaft

func NewRaft(peers []*utils.ClientEnd, me int, persister store.Persister, log *store.LogStorage, applyCh chan *ApplyMsg) *Raft

NewRaft create a raft instance peers used to communicate with other peers in this raft group, need to be construct in advance persister used to store metadata of raft, and log used for WAL applyCh, apply a command to state machine through this channel

func (*Raft) AppendEntries

func (rf *Raft) AppendEntries(ctx context.Context, req *pb.AppendEntriesReq) (res *pb.AppendEntriesRes, err error)

func (*Raft) IsLeader

func (rf *Raft) IsLeader() bool

func (*Raft) Kill

func (rf *Raft) Kill()

func (*Raft) RequestVote

func (rf *Raft) RequestVote(ctx context.Context, req *pb.RequestVoteReq) (res *pb.RequestVoteRes, err error)

func (*Raft) String

func (rf *Raft) String() string

func (*Raft) SubmitCommand

func (rf *Raft) SubmitCommand(ctx context.Context, command *pb.KVCommand) (isLeader bool, readOnly bool)

SubmitCommand submit a command to raft The command will be replicated to followers, then leader commmit, applied to the state machine by raftKV, and finally response to the client

func (*Raft) UpdateReadLease

func (rf *Raft) UpdateReadLease(term int32, lease time.Time)

type RequestVoteSession

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

func NewRequestVoteSession

func NewRequestVoteSession(me int, ctx context.Context, args *pb.RequestVoteReq, reply *pb.RequestVoteRes) *RequestVoteSession

Jump to

Keyboard shortcuts

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