Documentation ¶
Index ¶
- Constants
- Variables
- func GetBufferSize() int
- func GetFileSize(fileName string) (int64, error)
- func ReadEntryLog(entries []Entry) error
- func WriteEntryLog(entry Entry) error
- type AppendLog
- type AppendRequestMsg
- type DiskStore
- type Entry
- type Exponential
- type Message
- type Node
- func (n *Node) PersistToDisk(perm fs.FileMode, flag int) error
- func (n *Node) ReadNodeFromFile(buf []byte, flag int) *Node
- func (n *Node) RefreshFromDisk() *Node
- func (n *Node) SendRequestVote()
- func (n *Node) String() string
- func (n *Node) TruncNodeFile(size int64)
- func (n *Node) VoteForClient(client_name string, term int64, lastLogIdx int64, lastLogTerm int64) (int64, bool)
- type RequestVoteMsg
- type Store
Constants ¶
View Source
const ( Follower = "Follower" Candidate = "Candidate" Leader = "Leader" )
Variables ¶
View Source
var ( CurrentNode *Node NodeDetail = fmt.Sprintf("%s/.config/node-detail.json", os.Getenv("HOME")) EntryLogFile = fmt.Sprintf("%s/.config/entry_logs.json", os.Getenv("HOME")) )
View Source
var ( FileDir = ".data" FilePath = "" )
Functions ¶
func GetBufferSize ¶
func GetBufferSize() int
func GetFileSize ¶
func ReadEntryLog ¶
func WriteEntryLog ¶
Types ¶
type AppendLog ¶
func NewAppendLog ¶
func (*AppendLog) AddEntryToNode ¶
func (a *AppendLog) AddEntryToNode(req *pb.AppendEntryRequestDetail)
func (*AppendLog) AppendEntryLog ¶
func (a *AppendLog) AppendEntryLog(req *pb.AppendEntryRequestDetail) (*pb.AppendEntryResponse, error)
func (*AppendLog) SendAppendEntryLog ¶
func (a *AppendLog) SendAppendEntryLog()
func (*AppendLog) SendHeartBeat ¶
func (a *AppendLog) SendHeartBeat()
type AppendRequestMsg ¶
type AppendRequestMsg struct{}
func (*AppendRequestMsg) Send ¶
func (r *AppendRequestMsg) Send(server_name string, req *pb.AppendEntryRequestDetail) *pb.AppendEntryResponse
type Entry ¶
type Exponential ¶
type Exponential struct {
// contains filtered or unexported fields
}
func NewExponentialInterval ¶
func NewExponentialInterval(optMin, optMax, mult float64) *Exponential
func (*Exponential) Next ¶
func (e *Exponential) Next() time.Duration
type Node ¶
type Node struct { CurrentTerm int64 `json:"current_term,omitempty"` /* Store the term we're in atm */ VotedFor string `json:"voted_for,omitempty"` /* CandidateId that received vote */ State string `json:"state,omitempty"` /* Current state of the node */ Name string `json:"name,omitempty"` /* Node name */ CommitIndex int `json:"commit_index,omitempty"` /* Index of highest log entry known to be committed */ LastApplied int `json:"last_applied,omitempty"` /* Index of highest log entry applied to state machine */ Nodes []string `json:"nodes,omitempty"` /* Nodes in cluster */ LogEntry []Entry `json:"log_entry,omitempty"` /* Command Entries */ // contains filtered or unexported fields }
func NodeFromDisk ¶
func NodeFromDisk() *Node
func (*Node) RefreshFromDisk ¶
func (*Node) SendRequestVote ¶
func (n *Node) SendRequestVote()
func (*Node) TruncNodeFile ¶
type RequestVoteMsg ¶
type RequestVoteMsg struct{}
func (*RequestVoteMsg) Send ¶
func (r *RequestVoteMsg) Send(server_name string, term int64, cId string, lastLogIdx int64, lastLogTerm int64) *pb.RequestVoteResponse
Click to show internal directories.
Click to hide internal directories.