Versions in this module Expand all Collapse all v1 v1.1.0 Feb 20, 2023 v1.0.0 Feb 20, 2023 Changes in this version + const LocalAppendThread + const LocalApplyThread + const None + var ErrCompacted = errors.New("requested index is unavailable due to compaction") + var ErrProposalDropped = errors.New("raft proposal dropped") + var ErrPropose = errors.New("method Propose in NodeElect is not supported in election experiment") + var ErrReadIndex = errors.New("method ReadIndex in NodeElect is not supported in election experiment") + var ErrSnapOutOfDate = errors.New("requested index is older than the existing snapshot") + var ErrSnapshotTemporarilyUnavailable = errors.New("snapshot is temporarily unavailable") + var ErrStepLocalMsg = errors.New("raft: cannot step raft local message") + var ErrStepPeerNotFound = errors.New("raft: cannot step as peer not found") + var ErrStopped = errors.New("raft: stopped") + var ErrTransferLeader = errors.New(...) + var ErrUnavailable = errors.New("requested entry at index is unavailable") + func DescribeConfState(state pb.ConfState) string + func DescribeEntries(ents []pb.Entry, f EntryFormatter) string + func DescribeEntry(e pb.Entry, f EntryFormatter) string + func DescribeHardState(hs pb.HardState) string + func DescribeMessage(m pb.Message, f EntryFormatter) string + func DescribeReady(rd Ready, f EntryFormatter) string + func DescribeSnapshot(snap pb.Snapshot) string + func DescribeSoftState(ss SoftState) string + func IsEmptyHardState(st pb.HardState) bool + func IsEmptySnap(sp pb.Snapshot) bool + func IsLocalMsg(msgt pb.MessageType) bool + func IsLocalMsgTarget(id uint64) bool + func IsResponseMsg(msgt pb.MessageType) bool + func MustSync(st, prevst pb.HardState, entsnum int) bool + func ResetDefaultLogger() + func SetLogger(l Logger) + type BasicStatus struct + Applied uint64 + ID uint64 + LeadTransferee uint64 + type CampaignType string + type Config struct + Applied uint64 + AsyncStorageWrites bool + CheckQuorum bool + DisableProposalForwarding bool + ElectionTick int + HeartbeatTick int + ID uint64 + Logger Logger + MaxCommittedSizePerReady uint64 + MaxInflightBytes uint64 + MaxInflightMsgs int + MaxSizePerMsg uint64 + MaxUncommittedEntriesSize uint64 + PreVote bool + ReadOnlyOption ReadOnlyOption + Storage Storage + type DefaultLogger struct + func (l *DefaultLogger) Debug(v ...interface{}) + func (l *DefaultLogger) Debugf(format string, v ...interface{}) + func (l *DefaultLogger) EnableDebug() + func (l *DefaultLogger) EnableTimestamps() + func (l *DefaultLogger) Error(v ...interface{}) + func (l *DefaultLogger) Errorf(format string, v ...interface{}) + func (l *DefaultLogger) Fatal(v ...interface{}) + func (l *DefaultLogger) Fatalf(format string, v ...interface{}) + func (l *DefaultLogger) Info(v ...interface{}) + func (l *DefaultLogger) Infof(format string, v ...interface{}) + func (l *DefaultLogger) Panic(v ...interface{}) + func (l *DefaultLogger) Panicf(format string, v ...interface{}) + func (l *DefaultLogger) Warning(v ...interface{}) + func (l *DefaultLogger) Warningf(format string, v ...interface{}) + type EntryFormatter func([]byte) string + type Logger interface + Debug func(v ...interface{}) + Debugf func(format string, v ...interface{}) + Error func(v ...interface{}) + Errorf func(format string, v ...interface{}) + Fatal func(v ...interface{}) + Fatalf func(format string, v ...interface{}) + Info func(v ...interface{}) + Infof func(format string, v ...interface{}) + Panic func(v ...interface{}) + Panicf func(format string, v ...interface{}) + Warning func(v ...interface{}) + Warningf func(format string, v ...interface{}) + type MemoryStorage struct + func NewMemoryStorage() *MemoryStorage + func (ms *MemoryStorage) Append(entries []pb.Entry) error + func (ms *MemoryStorage) ApplySnapshot(snap pb.Snapshot) error + func (ms *MemoryStorage) Compact(compactIndex uint64) error + func (ms *MemoryStorage) CreateSnapshot(i uint64, cs *pb.ConfState, data []byte) (pb.Snapshot, error) + func (ms *MemoryStorage) Entries(lo, hi, maxSize uint64) ([]pb.Entry, error) + func (ms *MemoryStorage) FirstIndex() (uint64, error) + func (ms *MemoryStorage) InitialState() (pb.HardState, pb.ConfState, error) + func (ms *MemoryStorage) LastIndex() (uint64, error) + func (ms *MemoryStorage) SetHardState(st pb.HardState) error + func (ms *MemoryStorage) Snapshot() (pb.Snapshot, error) + func (ms *MemoryStorage) Term(i uint64) (uint64, error) + type Node interface + Advance func() + ApplyConfChange func(cc pb.ConfChangeI) *pb.ConfState + Campaign func(ctx context.Context) error + IsLeader func() bool + Propose func(ctx context.Context, data []byte) error + ProposeConfChange func(ctx context.Context, cc pb.ConfChangeI) error + ReadIndex func(ctx context.Context, rctx []byte) error + Ready func() <-chan Ready + ReportSnapshot func(id uint64, status SnapshotStatus) + ReportUnreachable func(id uint64) + Status func() Status + Step func(ctx context.Context, msg pb.Message) error + Stop func() + Tick func() + TransferLeadership func(ctx context.Context, lead, transferee uint64) + func RestartNode(c *Config) Node + func RestartNodeElect(c *Config, logger *zap.Logger) Node + func StartNode(c *Config, peers []Peer) Node + func StartNodeElect(c *Config, peers []Peer, logger *zap.Logger) Node + type NodeElect struct + func (ne *NodeElect) Advance() + func (ne *NodeElect) ApplyConfChange(cc pb.ConfChangeI) *pb.ConfState + func (ne *NodeElect) Campaign(ctx context.Context) error + func (ne *NodeElect) IsLeader() bool + func (ne *NodeElect) Propose(ctx context.Context, data []byte) error + func (ne *NodeElect) ProposeConfChange(ctx context.Context, cc pb.ConfChangeI) error + func (ne *NodeElect) ReadIndex(ctx context.Context, rctx []byte) error + func (ne *NodeElect) Ready() <-chan Ready + func (ne *NodeElect) ReportSnapshot(id uint64, status SnapshotStatus) + func (ne *NodeElect) ReportUnreachable(id uint64) + func (ne *NodeElect) Status() Status + func (ne *NodeElect) Step(ctx context.Context, m pb.Message) error + func (ne *NodeElect) Stop() + func (ne *NodeElect) Tick() + func (ne *NodeElect) TransferLeadership(ctx context.Context, lead, transferee uint64) + type Peer struct + Context []byte + ID uint64 + type ProgressType byte + const ProgressTypeLearner + const ProgressTypePeer + type RawNode struct + func NewRawNode(config *Config) (*RawNode, error) + func (rn *RawNode) Advance(_ Ready) + func (rn *RawNode) ApplyConfChange(cc pb.ConfChangeI) *pb.ConfState + func (rn *RawNode) BasicStatus() BasicStatus + func (rn *RawNode) Bootstrap(peers []Peer) error + func (rn *RawNode) Campaign() error + func (rn *RawNode) HasReady() bool + func (rn *RawNode) Propose(data []byte) error + func (rn *RawNode) ProposeConfChange(cc pb.ConfChangeI) error + func (rn *RawNode) ReadIndex(rctx []byte) + func (rn *RawNode) Ready() Ready + func (rn *RawNode) ReportSnapshot(id uint64, status SnapshotStatus) + func (rn *RawNode) ReportUnreachable(id uint64) + func (rn *RawNode) Status() Status + func (rn *RawNode) Step(m pb.Message) error + func (rn *RawNode) Tick() + func (rn *RawNode) TickQuiesced() + func (rn *RawNode) TransferLeader(transferee uint64) + func (rn *RawNode) WithProgress(visitor func(id uint64, typ ProgressType, pr tracker.Progress)) + type RawNodeElect struct + func NewRawNodeElect(config *Config, logger *zap.Logger) (*RawNodeElect, error) + func (rne *RawNodeElect) Advance(_ Ready) + func (rne *RawNodeElect) ApplyConfChange(cc pb.ConfChangeI) *pb.ConfState + func (rne *RawNodeElect) Bootstrap(peers []Peer) error + func (rne *RawNodeElect) Campaign() error + func (rne *RawNodeElect) HasReady() bool + func (rne *RawNodeElect) Step(m pb.Message) error + func (rne *RawNodeElect) Tick() + type ReadOnlyOption int + const ReadOnlyLeaseBased + const ReadOnlySafe + type ReadState struct + Index uint64 + RequestCtx []byte + type Ready struct + CommittedEntries []pb.Entry + Entries []pb.Entry + Messages []pb.Message + MustSync bool + ReadStates []ReadState + Snapshot pb.Snapshot + type SnapshotStatus int + const SnapshotFailure + const SnapshotFinish + type SoftState struct + Lead uint64 + RaftState StateType + type StateType uint64 + const StateCandidate + const StateFollower + const StateLeader + const StatePreCandidate + func (st StateType) MarshalJSON() ([]byte, error) + func (st StateType) String() string + type Status struct + Config tracker.Config + Progress map[uint64]tracker.Progress + func (s Status) MarshalJSON() ([]byte, error) + func (s Status) String() string + type Storage interface + Entries func(lo, hi, maxSize uint64) ([]pb.Entry, error) + FirstIndex func() (uint64, error) + InitialState func() (pb.HardState, pb.ConfState, error) + LastIndex func() (uint64, error) + Snapshot func() (pb.Snapshot, error) + Term func(i uint64) (uint64, error)