Documentation ¶
Index ¶
- Constants
- type Config
- type EntryStore
- type KVStore
- type Raft
- 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
Constants ¶
View Source
const ( FollowerState nodeState = "follower" CandidateState nodeState = "candidate" LeaderState nodeState = "leader" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config interface { GetRequestVoteTimeout() time.Duration GetAppendEntriesTimeout() time.Duration GetStartDelay() time.Duration GetCommitPeriod() time.Duration GetElectionTimeout() time.Duration GetLeaderStalePeriod() time.Duration GetLeaderHeartbeatPeriod() time.Duration GetLeaderHeartbeatBatchSize() uint64 }
type EntryStore ¶
type EntryStore interface { AppendEntries(ctx context.Context, entries ...*core.Entry) (err error) Last(ctx context.Context) (entry *core.Entry, err error) At(ctx context.Context, index uint64) (entry *core.Entry, err error) Range(ctx context.Context, from uint64, to uint64) (entries []*core.Entry, err error) }
type Raft ¶
type Raft struct {
// contains filtered or unexported fields
}
func NewRaftState ¶
func (*Raft) AppendEntries ¶
func (r *Raft) AppendEntries(ctx context.Context, req *desc.AppendEntriesRequest) (*desc.AppendEntriesResponse, error)
func (*Raft) Info ¶
func (r *Raft) Info(_ context.Context, _ *desc.InfoRequest) (*desc.InfoResponse, error)
func (*Raft) RequestVote ¶
func (r *Raft) RequestVote(ctx context.Context, req *desc.RequestVoteRequest) (*desc.RequestVoteResponse, error)
type StateStore ¶
type StateStore interface { GetTerm(ctx context.Context) (term uint64, err error) SetTerm(ctx context.Context, term uint64) (err error) GetCommit(ctx context.Context) (commitIndex uint64, err error) SetCommit(ctx context.Context, commitIndex uint64) (err error) GetLastApplied(ctx context.Context) (lastApplied uint64, err error) SetLastApplied(ctx context.Context, lastApplied uint64) (err error) GetVotedFor(ctx context.Context) (votedFor uint64, err error) SetVotedFor(ctx context.Context, votedFor uint64) (err error) }
Click to show internal directories.
Click to hide internal directories.