Versions in this module Expand all Collapse all v0 v0.1.0 Jun 17, 2020 Changes in this version + const LEADER + const NOT_LEADER + const None + const SnapshotFailure + const SnapshotFinish + var ErrCompacted = errors.New("requested index is unavailable due to compaction") + var ErrProposalDropped = errors.New("raft proposal dropped") + 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 ErrUnavailable = errors.New("requested entry at index is unavailable") + func DescribeEntry(e pb.Entry, f EntryFormatter) string + func DescribeMessage(m pb.Message, f EntryFormatter) string + func IsEmptyHardState(st pb.HardState) bool + func IsEmptySnap(sp pb.Snapshot) bool + func IsLocalMsg(msgt pb.MessageType) bool + func IsResponseMsg(msgt pb.MessageType) bool + func MustSync(st, prevst pb.HardState, entsnum int) bool + func SetLogger(l Logger) + type CampaignType string + type Config struct + Applied uint64 + CheckQuorum bool + DisableProposalForwarding bool + ElectionTick int + HeartbeatTick int + ID uint64 + Logger Logger + MaxInflightMsgs int + MaxSizePerMsg 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.ConfChange) *pb.ConfState + Campaign func(ctx context.Context) error + Propose func(ctx context.Context, data []byte) error + ProposeConfChange func(ctx context.Context, cc pb.ConfChange) error + ReadIndex func(ctx context.Context, rctx []byte) error + Ready func() <-chan Ready + ReportSnapshot func(id uint64, status SnapshotStatus) + ReportUnreachable func(id uint64) + RoleChan func() *channels.RingChannel + 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 StartNode(c *Config, peers []Peer) Node + type Peer struct + Context []byte + ID uint64 + type Progress struct + IsLearner bool + Match uint64 + Next uint64 + Paused bool + PendingSnapshot uint64 + RecentActive bool + State ProgressStateType + func (pr *Progress) IsPaused() bool + func (pr *Progress) String() string + type ProgressStateType uint64 + const ProgressStateProbe + const ProgressStateReplicate + const ProgressStateSnapshot + func (st ProgressStateType) String() string + type RawNode struct + func NewRawNode(config *Config, peers []Peer) (*RawNode, error) + func (rn *RawNode) Advance(rd Ready) + func (rn *RawNode) ApplyConfChange(cc pb.ConfChange) *pb.ConfState + func (rn *RawNode) Campaign() error + func (rn *RawNode) HasReady() bool + func (rn *RawNode) Propose(data []byte) error + func (rn *RawNode) ProposeConfChange(cc pb.ConfChange) 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) + 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 + 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 + Applied uint64 + ID uint64 + LeadTransferee uint64 + Progress map[uint64]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)