Documentation ¶
Index ¶
- Constants
- type AppendEntriesRequest
- type AppendEntriesResponse
- type Command
- type CommitIndexJson
- type Config
- type Envelope
- type Log
- type LogItem
- type Peer
- type RequestVoteRequest
- type RequestVoteResponse
- type Response
- type Server
- func (s *Server) Id() int
- func (s *Server) Inbox() chan Envelope
- func (s *Server) Leader() bool
- func (s *Server) LeaderId() int
- func (s *Server) Majority() int
- func (s *Server) Outbox() chan Envelope
- func (s *Server) Peers() []int
- func (s *Server) Port() int
- func (s *Server) RaftInbox() chan Command
- func (s *Server) RaftOutbox() chan Response
- func (s *Server) Start()
- func (s *Server) State() string
- func (s *Server) Stop()
- func (s *Server) Term() int64
- type TermJson
Constants ¶
View Source
const ( Get = "get" Put = "put" Delete = "delete" )
View Source
const ( Ok = "ok" Error = "error" Redirect = "redirect" )
View Source
const ( BROADCAST = -1 PATH_TO_CONFIG = "config.json" ELECTION_TIMEOUT = 300 //in millisecond HEARTBEAT_INTERVAL = 50 //in millisecond )
View Source
const ( Stopped = "stopped" Follower = "follower" Candidate = "candidate" Leader = "leader" )
states of server
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AppendEntriesRequest ¶
type AppendEntriesRequest struct { Term int64 //leader's term LeaderId int //so follower can redirect clients PrevLogIndex int64 //index of log entry immediately preceding new ones PrevLogTerm int64 //term of prevLogIndex entry Entries []LogItem //log items to store LeaderCommit int64 //leader’s commitIndex }
type AppendEntriesResponse ¶
type CommitIndexJson ¶
type CommitIndexJson struct {
CommitIndex int64
}
type Log ¶
type Log struct {
// contains filtered or unexported fields
}
func (*Log) CommitIndex ¶
func (*Log) CurrentIndex ¶
func (*Log) CurrentTerm ¶
type RequestVoteRequest ¶
type RequestVoteResponse ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.