Documentation
¶
Index ¶
- func EncodeRPCMsg(msg RPCMsg) ([]byte, error)
- func Panicf(format string, args ...interface{})
- func RecoverValueString(value interface{}) (msg string)
- func StackTrace(depth int) string
- type IncomingRPCMsg
- type LogEntry
- type LogIndex
- type LogReplayFunc
- type LogStore
- type Logger
- type PersistentState
- type PersistentStore
- type RPCAppendEntriesRequest
- type RPCAppendEntriesResponse
- type RPCMsg
- type RPCRequestVoteRequest
- type RPCRequestVoteResponse
- type Server
- type ServerAddress
- type ServerCfg
- type ServerData
- type ServerId
- type ServerSet
- type ServerState
- type Term
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EncodeRPCMsg ¶
func RecoverValueString ¶
func RecoverValueString(value interface{}) (msg string)
func StackTrace ¶
Types ¶
type IncomingRPCMsg ¶
type LogReplayFunc ¶
type LogStore ¶
type LogStore struct {
// contains filtered or unexported fields
}
func NewLogStore ¶
func (*LogStore) AppendEntries ¶
func (*LogStore) Open ¶
func (s *LogStore) Open(replayFn LogReplayFunc) error
type PersistentState ¶
type PersistentStore ¶
type PersistentStore struct {
// contains filtered or unexported fields
}
func NewPersistentStore ¶
func NewPersistentStore(filePath string) *PersistentStore
func (*PersistentStore) Close ¶
func (s *PersistentStore) Close()
func (*PersistentStore) Open ¶
func (s *PersistentStore) Open() error
func (*PersistentStore) Read ¶
func (s *PersistentStore) Read(state *PersistentState) error
func (*PersistentStore) Write ¶
func (s *PersistentStore) Write(state PersistentState) error
type RPCAppendEntriesRequest ¶
type RPCAppendEntriesRequest struct { Term Term LeaderId ServerId PrevLogIndex LogIndex PrevLogTerm Term Entries []LogEntry LeaderCommit LogIndex }
func (*RPCAppendEntriesRequest) GetTerm ¶
func (msg *RPCAppendEntriesRequest) GetTerm() Term
func (*RPCAppendEntriesRequest) GetType ¶
func (msg *RPCAppendEntriesRequest) GetType() string
func (*RPCAppendEntriesRequest) String ¶
func (msg *RPCAppendEntriesRequest) String() string
type RPCAppendEntriesResponse ¶
func (*RPCAppendEntriesResponse) GetTerm ¶
func (msg *RPCAppendEntriesResponse) GetTerm() Term
func (*RPCAppendEntriesResponse) GetType ¶
func (msg *RPCAppendEntriesResponse) GetType() string
func (*RPCAppendEntriesResponse) String ¶
func (msg *RPCAppendEntriesResponse) String() string
type RPCMsg ¶
func DecodeRPCMsg ¶
type RPCRequestVoteRequest ¶
type RPCRequestVoteRequest struct { Term Term CandidateId ServerId LastLogIndex LogIndex LastLogTerm Term }
func (*RPCRequestVoteRequest) GetTerm ¶
func (msg *RPCRequestVoteRequest) GetTerm() Term
func (*RPCRequestVoteRequest) GetType ¶
func (msg *RPCRequestVoteRequest) GetType() string
func (*RPCRequestVoteRequest) String ¶
func (msg *RPCRequestVoteRequest) String() string
type RPCRequestVoteResponse ¶
func (*RPCRequestVoteResponse) GetTerm ¶
func (msg *RPCRequestVoteResponse) GetTerm() Term
func (*RPCRequestVoteResponse) GetType ¶
func (msg *RPCRequestVoteResponse) GetType() string
func (*RPCRequestVoteResponse) String ¶
func (msg *RPCRequestVoteResponse) String() string
type Server ¶
type Server struct { Cfg ServerCfg Log Logger Id ServerId LocalAddress ServerAddress PublicAddress ServerAddress // contains filtered or unexported fields }
func (*Server) DataDirectoryPath ¶
type ServerAddress ¶
type ServerAddress = string
type ServerData ¶
type ServerData struct { LocalAddress ServerAddress `json:"local_address"` PublicAddress ServerAddress `json:"public_address"` }
type ServerSet ¶
type ServerSet map[ServerId]ServerData
type ServerState ¶
type ServerState string
const ( ServerStateFollower ServerState = "follower" ServerStateCandidate ServerState = "candidate" ServerStateLeader ServerState = "leader" )
Click to show internal directories.
Click to hide internal directories.