Documentation
¶
Index ¶
- Constants
- Variables
- func RegisterCommand(command Command)
- type AppendEntriesReq
- func (*AppendEntriesReq) Descriptor() ([]byte, []int)
- func (m *AppendEntriesReq) GetEntries() []*LogEntry
- func (m *AppendEntriesReq) GetLeaderCommit() uint64
- func (m *AppendEntriesReq) GetLeaderName() string
- func (m *AppendEntriesReq) GetPrevLogIndex() uint64
- func (m *AppendEntriesReq) GetPrevLogTerm() uint64
- func (m *AppendEntriesReq) GetTerm() uint64
- func (*AppendEntriesReq) ProtoMessage()
- func (m *AppendEntriesReq) Reset()
- func (m *AppendEntriesReq) String() string
- func (m *AppendEntriesReq) XXX_DiscardUnknown()
- func (m *AppendEntriesReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *AppendEntriesReq) XXX_Merge(src proto.Message)
- func (m *AppendEntriesReq) XXX_Size() int
- func (m *AppendEntriesReq) XXX_Unmarshal(b []byte) error
- type AppendEntriesResp
- func (*AppendEntriesResp) Descriptor() ([]byte, []int)
- func (m *AppendEntriesResp) GetConflictIndex() int64
- func (m *AppendEntriesResp) GetConflictTerm() int64
- func (m *AppendEntriesResp) GetSuccess() bool
- func (m *AppendEntriesResp) GetTerm() uint64
- func (*AppendEntriesResp) ProtoMessage()
- func (m *AppendEntriesResp) Reset()
- func (m *AppendEntriesResp) String() string
- func (m *AppendEntriesResp) XXX_DiscardUnknown()
- func (m *AppendEntriesResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *AppendEntriesResp) XXX_Merge(src proto.Message)
- func (m *AppendEntriesResp) XXX_Size() int
- func (m *AppendEntriesResp) XXX_Unmarshal(b []byte) error
- type ApplyMsg
- type ClientEnd
- type Command
- type CommandEncoder
- type InstallSnapshotReq
- func (*InstallSnapshotReq) Descriptor() ([]byte, []int)
- func (m *InstallSnapshotReq) GetData() []byte
- func (m *InstallSnapshotReq) GetDone() bool
- func (m *InstallSnapshotReq) GetLastIncludedIndex() uint64
- func (m *InstallSnapshotReq) GetLastIncludedTerm() uint64
- func (m *InstallSnapshotReq) GetLeaderName() string
- func (m *InstallSnapshotReq) GetOffset() uint64
- func (m *InstallSnapshotReq) GetTerm() uint64
- func (*InstallSnapshotReq) ProtoMessage()
- func (m *InstallSnapshotReq) Reset()
- func (m *InstallSnapshotReq) String() string
- func (m *InstallSnapshotReq) XXX_DiscardUnknown()
- func (m *InstallSnapshotReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *InstallSnapshotReq) XXX_Merge(src proto.Message)
- func (m *InstallSnapshotReq) XXX_Size() int
- func (m *InstallSnapshotReq) XXX_Unmarshal(b []byte) error
- type InstallSnapshotResp
- func (*InstallSnapshotResp) Descriptor() ([]byte, []int)
- func (m *InstallSnapshotResp) GetTerm() uint64
- func (*InstallSnapshotResp) ProtoMessage()
- func (m *InstallSnapshotResp) Reset()
- func (m *InstallSnapshotResp) String() string
- func (m *InstallSnapshotResp) XXX_DiscardUnknown()
- func (m *InstallSnapshotResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *InstallSnapshotResp) XXX_Merge(src proto.Message)
- func (m *InstallSnapshotResp) XXX_Size() int
- func (m *InstallSnapshotResp) XXX_Unmarshal(b []byte) error
- type LogEntry
- func (*LogEntry) Descriptor() ([]byte, []int)
- func (m *LogEntry) GetCommand() []byte
- func (m *LogEntry) GetCommandName() string
- func (m *LogEntry) GetIndex() uint64
- func (m *LogEntry) GetTerm() uint64
- func (*LogEntry) ProtoMessage()
- func (m *LogEntry) Reset()
- func (m *LogEntry) String() string
- func (m *LogEntry) XXX_DiscardUnknown()
- func (m *LogEntry) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *LogEntry) XXX_Merge(src proto.Message)
- func (m *LogEntry) XXX_Size() int
- func (m *LogEntry) XXX_Unmarshal(b []byte) error
- type Raft
- func (rf *Raft) AppendEntries(req *AppendEntriesReq, resp *AppendEntriesResp) (err error)
- func (rf *Raft) InstallSnapshot(req *InstallSnapshotReq, resp *InstallSnapshotResp) (err error)
- func (rf *Raft) MakeSnapshot(commitIdx uint64, snapshot []byte)
- func (rf *Raft) RequestVote(req *RequestVoteReq, resp *RequestVoteResp) (err error)
- func (rf *Raft) Stop()
- func (rf *Raft) Submit(command Command) (isLeader bool, err error)
- type RequestVoteReq
- func (*RequestVoteReq) Descriptor() ([]byte, []int)
- func (m *RequestVoteReq) GetCandidateName() string
- func (m *RequestVoteReq) GetLastLogIndex() uint64
- func (m *RequestVoteReq) GetLastLogTerm() uint64
- func (m *RequestVoteReq) GetTerm() uint64
- func (*RequestVoteReq) ProtoMessage()
- func (m *RequestVoteReq) Reset()
- func (m *RequestVoteReq) String() string
- func (m *RequestVoteReq) XXX_DiscardUnknown()
- func (m *RequestVoteReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *RequestVoteReq) XXX_Merge(src proto.Message)
- func (m *RequestVoteReq) XXX_Size() int
- func (m *RequestVoteReq) XXX_Unmarshal(b []byte) error
- type RequestVoteResp
- func (*RequestVoteResp) Descriptor() ([]byte, []int)
- func (m *RequestVoteResp) GetTerm() uint64
- func (m *RequestVoteResp) GetVoteGranted() bool
- func (*RequestVoteResp) ProtoMessage()
- func (m *RequestVoteResp) Reset()
- func (m *RequestVoteResp) String() string
- func (m *RequestVoteResp) XXX_DiscardUnknown()
- func (m *RequestVoteResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *RequestVoteResp) XXX_Merge(src proto.Message)
- func (m *RequestVoteResp) XXX_Size() int
- func (m *RequestVoteResp) XXX_Unmarshal(b []byte) error
- type State
Constants ¶
View Source
const NULL string = "null"
Variables ¶
View Source
var (
ErrNotLeader = fmt.Errorf("raft is not leader")
)
Functions ¶
Types ¶
type AppendEntriesReq ¶
type AppendEntriesReq struct {
Term uint64 `protobuf:"varint,1,opt,name=Term,proto3" json:"Term,omitempty"`
LeaderName string `protobuf:"bytes,2,opt,name=LeaderName,proto3" json:"LeaderName,omitempty"`
PrevLogIndex uint64 `protobuf:"varint,3,opt,name=PrevLogIndex,proto3" json:"PrevLogIndex,omitempty"`
PrevLogTerm uint64 `protobuf:"varint,4,opt,name=PrevLogTerm,proto3" json:"PrevLogTerm,omitempty"`
LeaderCommit uint64 `protobuf:"varint,5,opt,name=LeaderCommit,proto3" json:"LeaderCommit,omitempty"`
Entries []*LogEntry `protobuf:"bytes,6,rep,name=Entries,proto3" json:"Entries,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (*AppendEntriesReq) Descriptor ¶
func (*AppendEntriesReq) Descriptor() ([]byte, []int)
func (*AppendEntriesReq) GetEntries ¶
func (m *AppendEntriesReq) GetEntries() []*LogEntry
func (*AppendEntriesReq) GetLeaderCommit ¶
func (m *AppendEntriesReq) GetLeaderCommit() uint64
func (*AppendEntriesReq) GetLeaderName ¶
func (m *AppendEntriesReq) GetLeaderName() string
func (*AppendEntriesReq) GetPrevLogIndex ¶
func (m *AppendEntriesReq) GetPrevLogIndex() uint64
func (*AppendEntriesReq) GetPrevLogTerm ¶
func (m *AppendEntriesReq) GetPrevLogTerm() uint64
func (*AppendEntriesReq) GetTerm ¶
func (m *AppendEntriesReq) GetTerm() uint64
func (*AppendEntriesReq) ProtoMessage ¶
func (*AppendEntriesReq) ProtoMessage()
func (*AppendEntriesReq) Reset ¶
func (m *AppendEntriesReq) Reset()
func (*AppendEntriesReq) String ¶
func (m *AppendEntriesReq) String() string
func (*AppendEntriesReq) XXX_DiscardUnknown ¶
func (m *AppendEntriesReq) XXX_DiscardUnknown()
func (*AppendEntriesReq) XXX_Marshal ¶
func (m *AppendEntriesReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*AppendEntriesReq) XXX_Merge ¶
func (m *AppendEntriesReq) XXX_Merge(src proto.Message)
func (*AppendEntriesReq) XXX_Size ¶
func (m *AppendEntriesReq) XXX_Size() int
func (*AppendEntriesReq) XXX_Unmarshal ¶
func (m *AppendEntriesReq) XXX_Unmarshal(b []byte) error
type AppendEntriesResp ¶
type AppendEntriesResp struct {
Term uint64 `protobuf:"varint,1,opt,name=Term,proto3" json:"Term,omitempty"`
Success bool `protobuf:"varint,2,opt,name=Success,proto3" json:"Success,omitempty"`
ConflictTerm int64 `protobuf:"varint,3,opt,name=ConflictTerm,proto3" json:"ConflictTerm,omitempty"`
ConflictIndex int64 `protobuf:"varint,4,opt,name=ConflictIndex,proto3" json:"ConflictIndex,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (*AppendEntriesResp) Descriptor ¶
func (*AppendEntriesResp) Descriptor() ([]byte, []int)
func (*AppendEntriesResp) GetConflictIndex ¶
func (m *AppendEntriesResp) GetConflictIndex() int64
func (*AppendEntriesResp) GetConflictTerm ¶
func (m *AppendEntriesResp) GetConflictTerm() int64
func (*AppendEntriesResp) GetSuccess ¶
func (m *AppendEntriesResp) GetSuccess() bool
func (*AppendEntriesResp) GetTerm ¶
func (m *AppendEntriesResp) GetTerm() uint64
func (*AppendEntriesResp) ProtoMessage ¶
func (*AppendEntriesResp) ProtoMessage()
func (*AppendEntriesResp) Reset ¶
func (m *AppendEntriesResp) Reset()
func (*AppendEntriesResp) String ¶
func (m *AppendEntriesResp) String() string
func (*AppendEntriesResp) XXX_DiscardUnknown ¶
func (m *AppendEntriesResp) XXX_DiscardUnknown()
func (*AppendEntriesResp) XXX_Marshal ¶
func (m *AppendEntriesResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*AppendEntriesResp) XXX_Merge ¶
func (m *AppendEntriesResp) XXX_Merge(src proto.Message)
func (*AppendEntriesResp) XXX_Size ¶
func (m *AppendEntriesResp) XXX_Size() int
func (*AppendEntriesResp) XXX_Unmarshal ¶
func (m *AppendEntriesResp) XXX_Unmarshal(b []byte) error
type CommandEncoder ¶
type InstallSnapshotReq ¶
type InstallSnapshotReq struct {
Term uint64 `protobuf:"varint,1,opt,name=Term,proto3" json:"Term,omitempty"`
LeaderName string `protobuf:"bytes,2,opt,name=LeaderName,proto3" json:"LeaderName,omitempty"`
LastIncludedIndex uint64 `protobuf:"varint,3,opt,name=LastIncludedIndex,proto3" json:"LastIncludedIndex,omitempty"`
LastIncludedTerm uint64 `protobuf:"varint,4,opt,name=LastIncludedTerm,proto3" json:"LastIncludedTerm,omitempty"`
Offset uint64 `protobuf:"varint,5,opt,name=Offset,proto3" json:"Offset,omitempty"`
Data []byte `protobuf:"bytes,6,opt,name=Data,proto3" json:"Data,omitempty"`
Done bool `protobuf:"varint,7,opt,name=Done,proto3" json:"Done,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (*InstallSnapshotReq) Descriptor ¶
func (*InstallSnapshotReq) Descriptor() ([]byte, []int)
func (*InstallSnapshotReq) GetData ¶
func (m *InstallSnapshotReq) GetData() []byte
func (*InstallSnapshotReq) GetDone ¶
func (m *InstallSnapshotReq) GetDone() bool
func (*InstallSnapshotReq) GetLastIncludedIndex ¶
func (m *InstallSnapshotReq) GetLastIncludedIndex() uint64
func (*InstallSnapshotReq) GetLastIncludedTerm ¶
func (m *InstallSnapshotReq) GetLastIncludedTerm() uint64
func (*InstallSnapshotReq) GetLeaderName ¶
func (m *InstallSnapshotReq) GetLeaderName() string
func (*InstallSnapshotReq) GetOffset ¶
func (m *InstallSnapshotReq) GetOffset() uint64
func (*InstallSnapshotReq) GetTerm ¶
func (m *InstallSnapshotReq) GetTerm() uint64
func (*InstallSnapshotReq) ProtoMessage ¶
func (*InstallSnapshotReq) ProtoMessage()
func (*InstallSnapshotReq) Reset ¶
func (m *InstallSnapshotReq) Reset()
func (*InstallSnapshotReq) String ¶
func (m *InstallSnapshotReq) String() string
func (*InstallSnapshotReq) XXX_DiscardUnknown ¶
func (m *InstallSnapshotReq) XXX_DiscardUnknown()
func (*InstallSnapshotReq) XXX_Marshal ¶
func (m *InstallSnapshotReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*InstallSnapshotReq) XXX_Merge ¶
func (m *InstallSnapshotReq) XXX_Merge(src proto.Message)
func (*InstallSnapshotReq) XXX_Size ¶
func (m *InstallSnapshotReq) XXX_Size() int
func (*InstallSnapshotReq) XXX_Unmarshal ¶
func (m *InstallSnapshotReq) XXX_Unmarshal(b []byte) error
type InstallSnapshotResp ¶
type InstallSnapshotResp struct {
Term uint64 `protobuf:"varint,1,opt,name=Term,proto3" json:"Term,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (*InstallSnapshotResp) Descriptor ¶
func (*InstallSnapshotResp) Descriptor() ([]byte, []int)
func (*InstallSnapshotResp) GetTerm ¶
func (m *InstallSnapshotResp) GetTerm() uint64
func (*InstallSnapshotResp) ProtoMessage ¶
func (*InstallSnapshotResp) ProtoMessage()
func (*InstallSnapshotResp) Reset ¶
func (m *InstallSnapshotResp) Reset()
func (*InstallSnapshotResp) String ¶
func (m *InstallSnapshotResp) String() string
func (*InstallSnapshotResp) XXX_DiscardUnknown ¶
func (m *InstallSnapshotResp) XXX_DiscardUnknown()
func (*InstallSnapshotResp) XXX_Marshal ¶
func (m *InstallSnapshotResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*InstallSnapshotResp) XXX_Merge ¶
func (m *InstallSnapshotResp) XXX_Merge(src proto.Message)
func (*InstallSnapshotResp) XXX_Size ¶
func (m *InstallSnapshotResp) XXX_Size() int
func (*InstallSnapshotResp) XXX_Unmarshal ¶
func (m *InstallSnapshotResp) XXX_Unmarshal(b []byte) error
type LogEntry ¶
type LogEntry struct {
Index uint64 `protobuf:"varint,1,opt,name=Index,proto3" json:"Index,omitempty"`
Term uint64 `protobuf:"varint,2,opt,name=Term,proto3" json:"Term,omitempty"`
CommandName string `protobuf:"bytes,3,opt,name=CommandName,proto3" json:"CommandName,omitempty"`
Command []byte `protobuf:"bytes,4,opt,name=Command,proto3" json:"Command,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (*LogEntry) Descriptor ¶
func (*LogEntry) GetCommand ¶
func (*LogEntry) GetCommandName ¶
func (*LogEntry) ProtoMessage ¶
func (*LogEntry) ProtoMessage()
func (*LogEntry) XXX_DiscardUnknown ¶
func (m *LogEntry) XXX_DiscardUnknown()
func (*LogEntry) XXX_Marshal ¶
func (*LogEntry) XXX_Unmarshal ¶
type Raft ¶
func (*Raft) AppendEntries ¶
func (rf *Raft) AppendEntries(req *AppendEntriesReq, resp *AppendEntriesResp) (err error)
func (*Raft) InstallSnapshot ¶
func (rf *Raft) InstallSnapshot(req *InstallSnapshotReq, resp *InstallSnapshotResp) (err error)
func (*Raft) MakeSnapshot ¶
func (*Raft) RequestVote ¶
func (rf *Raft) RequestVote(req *RequestVoteReq, resp *RequestVoteResp) (err error)
type RequestVoteReq ¶
type RequestVoteReq struct {
Term uint64 `protobuf:"varint,1,opt,name=Term,proto3" json:"Term,omitempty"`
LastLogIndex uint64 `protobuf:"varint,2,opt,name=LastLogIndex,proto3" json:"LastLogIndex,omitempty"`
LastLogTerm uint64 `protobuf:"varint,3,opt,name=LastLogTerm,proto3" json:"LastLogTerm,omitempty"`
CandidateName string `protobuf:"bytes,4,opt,name=CandidateName,proto3" json:"CandidateName,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (*RequestVoteReq) Descriptor ¶
func (*RequestVoteReq) Descriptor() ([]byte, []int)
func (*RequestVoteReq) GetCandidateName ¶
func (m *RequestVoteReq) GetCandidateName() string
func (*RequestVoteReq) GetLastLogIndex ¶
func (m *RequestVoteReq) GetLastLogIndex() uint64
func (*RequestVoteReq) GetLastLogTerm ¶
func (m *RequestVoteReq) GetLastLogTerm() uint64
func (*RequestVoteReq) GetTerm ¶
func (m *RequestVoteReq) GetTerm() uint64
func (*RequestVoteReq) ProtoMessage ¶
func (*RequestVoteReq) ProtoMessage()
func (*RequestVoteReq) Reset ¶
func (m *RequestVoteReq) Reset()
func (*RequestVoteReq) String ¶
func (m *RequestVoteReq) String() string
func (*RequestVoteReq) XXX_DiscardUnknown ¶
func (m *RequestVoteReq) XXX_DiscardUnknown()
func (*RequestVoteReq) XXX_Marshal ¶
func (m *RequestVoteReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*RequestVoteReq) XXX_Merge ¶
func (m *RequestVoteReq) XXX_Merge(src proto.Message)
func (*RequestVoteReq) XXX_Size ¶
func (m *RequestVoteReq) XXX_Size() int
func (*RequestVoteReq) XXX_Unmarshal ¶
func (m *RequestVoteReq) XXX_Unmarshal(b []byte) error
type RequestVoteResp ¶
type RequestVoteResp struct {
Term uint64 `protobuf:"varint,1,opt,name=Term,proto3" json:"Term,omitempty"`
VoteGranted bool `protobuf:"varint,2,opt,name=VoteGranted,proto3" json:"VoteGranted,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (*RequestVoteResp) Descriptor ¶
func (*RequestVoteResp) Descriptor() ([]byte, []int)
func (*RequestVoteResp) GetTerm ¶
func (m *RequestVoteResp) GetTerm() uint64
func (*RequestVoteResp) GetVoteGranted ¶
func (m *RequestVoteResp) GetVoteGranted() bool
func (*RequestVoteResp) ProtoMessage ¶
func (*RequestVoteResp) ProtoMessage()
func (*RequestVoteResp) Reset ¶
func (m *RequestVoteResp) Reset()
func (*RequestVoteResp) String ¶
func (m *RequestVoteResp) String() string
func (*RequestVoteResp) XXX_DiscardUnknown ¶
func (m *RequestVoteResp) XXX_DiscardUnknown()
func (*RequestVoteResp) XXX_Marshal ¶
func (m *RequestVoteResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*RequestVoteResp) XXX_Merge ¶
func (m *RequestVoteResp) XXX_Merge(src proto.Message)
func (*RequestVoteResp) XXX_Size ¶
func (m *RequestVoteResp) XXX_Size() int
func (*RequestVoteResp) XXX_Unmarshal ¶
func (m *RequestVoteResp) XXX_Unmarshal(b []byte) error
Source Files
¶
Click to show internal directories.
Click to hide internal directories.