Documentation
¶
Index ¶
- Constants
- type AppendEntriesSession
- type ApplyMsg
- type Raft
- func (rf *Raft) AppendEntries(ctx context.Context, req *pb.AppendEntriesReq) (res *pb.AppendEntriesRes, err error)
- func (rf *Raft) IsLeader() bool
- func (rf *Raft) Kill()
- func (rf *Raft) RequestVote(ctx context.Context, req *pb.RequestVoteReq) (res *pb.RequestVoteRes, err error)
- func (rf *Raft) String() string
- func (rf *Raft) SubmitCommand(ctx context.Context, command *pb.KVCommand) (isLeader bool, readOnly bool)
- func (rf *Raft) UpdateReadLease(term int32, lease time.Time)
- type RequestVoteSession
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 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) RequestVote ¶
func (rf *Raft) RequestVote(ctx context.Context, req *pb.RequestVoteReq) (res *pb.RequestVoteRes, err error)
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
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
Click to show internal directories.
Click to hide internal directories.