Versions in this module Expand all Collapse all v0 v0.0.1 Dec 15, 2024 Changes in this version + const CandidateState + const FollowerState + const LeaderState + type Config interface + GetAppendEntriesTimeout func() time.Duration + GetCommitPeriod func() time.Duration + GetElectionTimeout func() time.Duration + GetLeaderHeartbeatBatchSize func() uint64 + GetLeaderHeartbeatPeriod func() time.Duration + GetLeaderStalePeriod func() time.Duration + GetRequestVoteTimeout func() time.Duration + GetStartDelay func() time.Duration + type EntryStore interface + AppendEntries func(ctx context.Context, entries ...*core.Entry) (err error) + At func(ctx context.Context, index uint64) (entry *core.Entry, err error) + Last func(ctx context.Context) (entry *core.Entry, err error) + Range func(ctx context.Context, from uint64, to uint64) (entries []*core.Entry, err error) + type KVStore interface + Del func(ctx context.Context, key string) (err error) + Get func(ctx context.Context, key string) (value string, err error) + Set func(ctx context.Context, key, value string) (err error) + type Raft struct + func NewRaftState(ctx context.Context, config Config, raftID core.ServerID, cluster []core.Node, ...) (*Raft, error) + func (r *Raft) AppendEntries(ctx context.Context, req *desc.AppendEntriesRequest) (*desc.AppendEntriesResponse, error) + func (r *Raft) Close() error + func (r *Raft) Del(ctx context.Context, key string) error + func (r *Raft) Get(ctx context.Context, key string) (string, error) + func (r *Raft) Info(_ context.Context, _ *desc.InfoRequest) (*desc.InfoResponse, error) + func (r *Raft) RequestVote(ctx context.Context, req *desc.RequestVoteRequest) (*desc.RequestVoteResponse, error) + func (r *Raft) Run() + func (r *Raft) Set(ctx context.Context, key string, value string) error + type StateStore interface + GetCommit func(ctx context.Context) (commitIndex uint64, err error) + GetLastApplied func(ctx context.Context) (lastApplied uint64, err error) + GetTerm func(ctx context.Context) (term uint64, err error) + GetVotedFor func(ctx context.Context) (votedFor uint64, err error) + SetCommit func(ctx context.Context, commitIndex uint64) (err error) + SetLastApplied func(ctx context.Context, lastApplied uint64) (err error) + SetTerm func(ctx context.Context, term uint64) (err error) + SetVotedFor func(ctx context.Context, votedFor uint64) (err error)