Documentation
¶
Index ¶
- type MetaStore
- type Metadata
- type Node
- func (n *Node) Address() string
- func (n *Node) AppendCommand(cmd *pb.Command) uint64
- func (n *Node) AppendEntriesToLog(prevLogIndex uint64, entries []*pb.LogEntry) bool
- func (n *Node) BecomeFollower(term uint64)
- func (n *Node) BecomeLeader()
- func (n *Node) CanGrantVote(candidateID string, ...) (voteGranted bool, currTerm uint64)
- func (n *Node) ClusterSize() int
- func (n *Node) CommitIndex() uint64
- func (n *Node) CurrentTerm() uint64
- func (n *Node) ElectionTimerLoop()
- func (n *Node) GetLogEntries(startIndex uint64) []*pb.LogEntry
- func (n *Node) GetLogEntry(index uint64) *pb.LogEntry
- func (n *Node) GetMatchIndex(peerAddr string) uint64
- func (n *Node) GetNextIndex(peerAddr string) uint64
- func (n *Node) GetPrevLogInfo(nextIndex uint64) (prevLogIndex, prevLogTerm uint64)
- func (n *Node) GetValue(key string) (string, bool)
- func (n *Node) HandleElectionTimeout()
- func (n *Node) HandleInstallSnapshot(term uint64, leaderID string, lastIncludedIndex uint64, ...) uint64
- func (n *Node) ID() string
- func (n *Node) IsLogUpToDate(candidateLastLogIndex, candidateLastLogTerm uint64) bool
- func (n *Node) LastIncludedIndex() uint64
- func (n *Node) LastIncludedTerm() uint64
- func (n *Node) LastLogIndex() uint64
- func (n *Node) LastLogTerm() uint64
- func (n *Node) LeaderAddr() string
- func (n *Node) LoadSnapshot() (*Snapshot, error)
- func (n *Node) LogLength() uint64
- func (n *Node) MajoritySize() int
- func (n *Node) MatchesPrevLog(prevLogIndex, prevLogTerm uint64) bool
- func (n *Node) Peers() []string
- func (n *Node) ResetElectionTimer()
- func (n *Node) SetCallbacks(onBecomeCandidate func(), onSendHeartbeat func())
- func (n *Node) SetCommitIndex(index uint64)
- func (n *Node) SetLeaderAddr(addr string)
- func (n *Node) SetMatchIndex(peerAddr string, index uint64)
- func (n *Node) SetNextIndex(peerAddr string, index uint64)
- func (n *Node) SetState(state NodeState)
- func (n *Node) SetVotedFor(candidateID string)
- func (n *Node) StartElectionTimer()
- func (n *Node) StartHeartbeatLoop()
- func (n *Node) State() NodeState
- func (n *Node) StopTimers()
- func (n *Node) UpdateCommitIndex()
- func (n *Node) VotedFor() string
- type NodeState
- type Server
- func (s *Server) AppendEntries(ctx context.Context, req *pb.AppendEntriesRequest) (*pb.AppendEntriesResponse, error)
- func (s *Server) ConnectToPeers()
- func (s *Server) GetLeaderHttpAddr() string
- func (s *Server) InstallSnapshot(ctx context.Context, req *pb.InstallSnapshotRequest) (*pb.InstallSnapshotResponse, error)
- func (s *Server) Node() *Node
- func (s *Server) Ping(ctx context.Context, req *pb.PingRequest) (*pb.PingResponse, error)
- func (s *Server) RequestVote(ctx context.Context, req *pb.RequestVoteRequest) (*pb.RequestVoteResponse, error)
- func (s *Server) Start() error
- func (s *Server) Stop()
- type Snapshot
- type SnapshotStore
- type WAL
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MetaStore ¶
type MetaStore struct {
// contains filtered or unexported fields
}
func OpenMetaStore ¶
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
func (*Node) AppendEntriesToLog ¶
func (*Node) BecomeFollower ¶
func (*Node) BecomeLeader ¶
func (n *Node) BecomeLeader()
func (*Node) CanGrantVote ¶
func (*Node) ClusterSize ¶
func (*Node) CommitIndex ¶
func (*Node) CurrentTerm ¶
func (*Node) ElectionTimerLoop ¶
func (n *Node) ElectionTimerLoop()
func (*Node) GetMatchIndex ¶
func (*Node) GetNextIndex ¶
func (*Node) GetPrevLogInfo ¶
func (*Node) HandleElectionTimeout ¶
func (n *Node) HandleElectionTimeout()
func (*Node) HandleInstallSnapshot ¶
func (*Node) IsLogUpToDate ¶
func (*Node) LastIncludedIndex ¶
func (*Node) LastIncludedTerm ¶
func (*Node) LastLogIndex ¶
func (*Node) LastLogTerm ¶
func (*Node) LeaderAddr ¶
func (*Node) LoadSnapshot ¶
func (*Node) MajoritySize ¶
func (*Node) MatchesPrevLog ¶
func (*Node) ResetElectionTimer ¶
func (n *Node) ResetElectionTimer()
func (*Node) SetCallbacks ¶
func (n *Node) SetCallbacks(onBecomeCandidate func(), onSendHeartbeat func())
func (*Node) SetCommitIndex ¶
func (*Node) SetLeaderAddr ¶
func (*Node) SetMatchIndex ¶
func (*Node) SetNextIndex ¶
func (*Node) SetVotedFor ¶
func (*Node) StartElectionTimer ¶
func (n *Node) StartElectionTimer()
func (*Node) StartHeartbeatLoop ¶
func (n *Node) StartHeartbeatLoop()
func (*Node) StopTimers ¶
func (n *Node) StopTimers()
func (*Node) UpdateCommitIndex ¶
func (n *Node) UpdateCommitIndex()
type Server ¶
type Server struct {
pb.UnimplementedRaftServiceServer
// contains filtered or unexported fields
}
func (*Server) AppendEntries ¶
func (s *Server) AppendEntries(ctx context.Context, req *pb.AppendEntriesRequest) (*pb.AppendEntriesResponse, error)
func (*Server) ConnectToPeers ¶
func (s *Server) ConnectToPeers()
func (*Server) GetLeaderHttpAddr ¶
func (*Server) InstallSnapshot ¶
func (s *Server) InstallSnapshot(ctx context.Context, req *pb.InstallSnapshotRequest) (*pb.InstallSnapshotResponse, error)
func (*Server) Ping ¶
func (s *Server) Ping(ctx context.Context, req *pb.PingRequest) (*pb.PingResponse, error)
func (*Server) RequestVote ¶
func (s *Server) RequestVote(ctx context.Context, req *pb.RequestVoteRequest) (*pb.RequestVoteResponse, error)
type SnapshotStore ¶
type SnapshotStore struct {
// contains filtered or unexported fields
}
func OpenSnapshotStore ¶
func OpenSnapshotStore(dir string) *SnapshotStore
func (*SnapshotStore) LoadSnapshot ¶
func (s *SnapshotStore) LoadSnapshot() (*Snapshot, error)
func (*SnapshotStore) SaveSnapshot ¶
func (s *SnapshotStore) SaveSnapshot(snap *Snapshot) error
Click to show internal directories.
Click to hide internal directories.