Versions in this module Expand all Collapse all v0 v0.1.0 Aug 11, 2013 Changes in this version + const Candidate + const Debug + const DefaultElectionTimeout + const DefaultHeartbeatTimeout + const Follower + const Leader + const MaxLogEntriesPerRequest + const NumberOfLogEntriesAfterSnapshot + const READY + const RUNNING + const STOPPED + const Snapshotting + const Stopped + const Trace + var CommandTimeoutError = errors.New("raft: Command timeout") + var DuplicatePeerError = errors.New("raft.Server: Duplicate peer") + var NotLeaderError = errors.New("raft.Server: Not current leader") + func LogLevel() int + func RegisterCommand(command Command) + func SetLogLevel(level int) + type AppendEntriesRequest struct + CommitIndex uint64 + Entries []*LogEntry + LeaderName string + PrevLogIndex uint64 + PrevLogTerm uint64 + Term uint64 + type AppendEntriesResponse struct + CommitIndex uint64 + Index uint64 + Success bool + Term uint64 + type Command interface + Apply func(server *Server) (interface{}, error) + CommandName func() string + type CommandEncoder interface + Decode func(r io.Reader) error + Encode func(w io.Writer) error + type DefaultJoinCommand struct + Name string + func (c *DefaultJoinCommand) Apply(server *Server) (interface{}, error) + func (c *DefaultJoinCommand) CommandName() string + func (c *DefaultJoinCommand) NodeName() string + type DefaultLeaveCommand struct + Name string + func (c *DefaultLeaveCommand) Apply(server *Server) (interface{}, error) + func (c *DefaultLeaveCommand) CommandName() string + func (c *DefaultLeaveCommand) NodeName() string + type HTTPMuxer interface + HandleFunc func(string, func(http.ResponseWriter, *http.Request)) + type HTTPTransporter struct + DisableKeepAlives bool + func NewHTTPTransporter(prefix string) *HTTPTransporter + func (t *HTTPTransporter) AppendEntriesPath() string + func (t *HTTPTransporter) Install(server *Server, mux HTTPMuxer) + func (t *HTTPTransporter) Prefix() string + func (t *HTTPTransporter) RequestVotePath() string + func (t *HTTPTransporter) SendAppendEntriesRequest(server *Server, peer *Peer, req *AppendEntriesRequest) *AppendEntriesResponse + func (t *HTTPTransporter) SendSnapshotRecoveryRequest(server *Server, peer *Peer, req *SnapshotRecoveryRequest) *SnapshotRecoveryResponse + func (t *HTTPTransporter) SendSnapshotRequest(server *Server, peer *Peer, req *SnapshotRequest) *SnapshotResponse + func (t *HTTPTransporter) SendVoteRequest(server *Server, peer *Peer, req *RequestVoteRequest) *RequestVoteResponse + type JoinCommand interface + Apply func(server *Server) (interface{}, error) + CommandName func() string + NodeName func() string + type LeaveCommand interface + Apply func(server *Server) (interface{}, error) + CommandName func() string + NodeName func() string + type Log struct + ApplyFunc func(Command) (interface{}, error) + func (l *Log) CommitIndex() uint64 + type LogEntry struct + Command []byte + CommandName string + Index uint64 + Position int64 + Term uint64 + type NOPCommand struct + func (c NOPCommand) Apply(server *Server) (interface{}, error) + func (c NOPCommand) CommandName() string + func (c NOPCommand) Decode(r io.Reader) error + func (c NOPCommand) Encode(w io.Writer) error + type Peer struct + func (p *Peer) Name() string + type RequestVoteRequest struct + CandidateName string + LastLogIndex uint64 + LastLogTerm uint64 + Term uint64 + type RequestVoteResponse struct + Term uint64 + VoteGranted bool + type Server struct + func NewServer(name string, path string, transporter Transporter, stateMachine StateMachine, ...) (*Server, error) + func (s *Server) AddPeer(name string) error + func (s *Server) AppendEntries(req *AppendEntriesRequest) *AppendEntriesResponse + func (s *Server) CommitIndex() uint64 + func (s *Server) Context() interface{} + func (s *Server) Do(command Command) (interface{}, error) + func (s *Server) ElectionTimeout() time.Duration + func (s *Server) GetState() string + func (s *Server) HeartbeatTimeout() time.Duration + func (s *Server) IsLogEmpty() bool + func (s *Server) LastCommandName() string + func (s *Server) Leader() string + func (s *Server) LoadSnapshot() error + func (s *Server) LogEntries() []*LogEntry + func (s *Server) LogPath() string + func (s *Server) MemberCount() int + func (s *Server) Name() string + func (s *Server) Path() string + func (s *Server) Peers() map[string]*Peer + func (s *Server) QuorumSize() int + func (s *Server) RemovePeer(name string) error + func (s *Server) RequestSnapshot(req *SnapshotRequest) *SnapshotResponse + func (s *Server) RequestVote(req *RequestVoteRequest) *RequestVoteResponse + func (s *Server) Running() bool + func (s *Server) SetElectionTimeout(duration time.Duration) + func (s *Server) SetHeartbeatTimeout(duration time.Duration) + func (s *Server) SetTransporter(t Transporter) + func (s *Server) Snapshot() + func (s *Server) SnapshotPath(lastIndex uint64, lastTerm uint64) string + func (s *Server) SnapshotRecoveryRequest(req *SnapshotRecoveryRequest) *SnapshotRecoveryResponse + func (s *Server) Start() error + func (s *Server) State() string + func (s *Server) Stop() + func (s *Server) Term() uint64 + func (s *Server) Transporter() Transporter + func (s *Server) VotedFor() string + type Snapshot struct + LastIndex uint64 + LastTerm uint64 + Path string + Peers []string + State []byte + type SnapshotRecoveryRequest struct + LastIndex uint64 + LastTerm uint64 + LeaderName string + Peers []string + State []byte + type SnapshotRecoveryResponse struct + CommitIndex uint64 + Success bool + Term uint64 + type SnapshotRequest struct + LastIndex uint64 + LastTerm uint64 + LeaderName string + type SnapshotResponse struct + Success bool + type StateMachine interface + Recovery func([]byte) error + Save func() ([]byte, error) + type Transporter interface + SendAppendEntriesRequest func(server *Server, peer *Peer, req *AppendEntriesRequest) *AppendEntriesResponse + SendSnapshotRecoveryRequest func(server *Server, peer *Peer, req *SnapshotRecoveryRequest) *SnapshotRecoveryResponse + SendSnapshotRequest func(server *Server, peer *Peer, req *SnapshotRequest) *SnapshotResponse + SendVoteRequest func(server *Server, peer *Peer, req *RequestVoteRequest) *RequestVoteResponse