Versions in this module Expand all Collapse all v0 v0.2.2 Feb 4, 2015 v0.2.1 Jan 28, 2015 Changes in this version + const AddPeerEventType + const Candidate + const CommitEventType + const Debug + const DefaultElectionTimeout + const DefaultHeartbeatInterval + const ElectionTimeoutThresholdEventType + const ElectionTimeoutThresholdPercent + const Follower + const HeartbeatEventType + const HeartbeatIntervalEventType + const Initialized + const Leader + const LeaderChangeEventType + const MaxLogEntriesPerRequest + const NumberOfLogEntriesAfterSnapshot + const RemovePeerEventType + const RemovedEventType + const Snapshotting + const StateChangeEventType + const Stopped + const TermChangeEventType + 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") + var StopError = errors.New("raft: Has been stopped") + func LogLevel() int + func RegisterCommand(command Command) + func SetLogLevel(level int) + type AppendEntriesRequest struct + CommitIndex uint64 + Entries []*protobuf.LogEntry + LeaderName string + PrevLogIndex uint64 + PrevLogTerm uint64 + Term uint64 + func (req *AppendEntriesRequest) Decode(r io.Reader) (int, error) + func (req *AppendEntriesRequest) Encode(w io.Writer) (int, error) + type AppendEntriesResponse struct + func (aer *AppendEntriesResponse) CommitIndex() uint64 + func (aer *AppendEntriesResponse) Index() uint64 + func (aer *AppendEntriesResponse) Success() bool + func (aer *AppendEntriesResponse) Term() uint64 + func (resp *AppendEntriesResponse) Decode(r io.Reader) (int, error) + func (resp *AppendEntriesResponse) Encode(w io.Writer) (int, error) + type Command interface + CommandName func() string + type CommandApply interface + Apply func(Context) (interface{}, error) + type CommandEncoder interface + Decode func(r io.Reader) error + Encode func(w io.Writer) error + type Config struct + CommitIndex uint64 + Peers []*Peer + type Context interface + CommitIndex func() uint64 + CurrentIndex func() uint64 + CurrentTerm func() uint64 + Server func() Server + type DefaultJoinCommand struct + ConnectionString string + 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 Event interface + PrevValue func() interface{} + Source func() interface{} + Type func() string + Value func() interface{} + type EventListener func(Event) + type HTTPMuxer interface + HandleFunc func(string, func(http.ResponseWriter, *http.Request)) + type HTTPTransporter struct + DisableKeepAlives bool + Transport *http.Transport + func NewHTTPTransporter(prefix string, timeout time.Duration) *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 + func (t *HTTPTransporter) SnapshotPath() string + func (t *HTTPTransporter) SnapshotRecoveryPath() string + type JoinCommand interface + NodeName func() string + type LeaveCommand interface + NodeName func() string + type Log struct + ApplyFunc func(*LogEntry, Command) (interface{}, error) + func (l *Log) CommitIndex() uint64 + type LogEntry struct + Position int64 + func (e *LogEntry) Command() []byte + func (e *LogEntry) CommandName() string + func (e *LogEntry) Decode(r io.Reader) (int, error) + func (e *LogEntry) Encode(w io.Writer) (int, error) + func (e *LogEntry) Index() uint64 + func (e *LogEntry) 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 + ConnectionString string + Name string + func (p *Peer) LastActivity() time.Time + type RequestVoteRequest struct + CandidateName string + LastLogIndex uint64 + LastLogTerm uint64 + Term uint64 + func (req *RequestVoteRequest) Decode(r io.Reader) (int, error) + func (req *RequestVoteRequest) Encode(w io.Writer) (int, error) + type RequestVoteResponse struct + Term uint64 + VoteGranted bool + func (resp *RequestVoteResponse) Decode(r io.Reader) (int, error) + func (resp *RequestVoteResponse) Encode(w io.Writer) (int, error) + type Server interface + AddEventListener func(string, EventListener) + AddPeer func(name string, connectiongString string) error + AppendEntries func(req *AppendEntriesRequest) *AppendEntriesResponse + CommitIndex func() uint64 + Context func() interface{} + Do func(command Command) (interface{}, error) + ElectionTimeout func() time.Duration + FlushCommitIndex func() + GetState func() string + HeartbeatInterval func() time.Duration + Init func() error + IsLogEmpty func() bool + LastCommandName func() string + Leader func() string + LoadSnapshot func() error + LogEntries func() []*LogEntry + LogPath func() string + MemberCount func() int + Name func() string + Path func() string + Peers func() map[string]*Peer + QuorumSize func() int + RemovePeer func(name string) error + RequestSnapshot func(req *SnapshotRequest) *SnapshotResponse + RequestVote func(req *RequestVoteRequest) *RequestVoteResponse + Running func() bool + SetElectionTimeout func(duration time.Duration) + SetHeartbeatInterval func(duration time.Duration) + SetTransporter func(t Transporter) + SnapshotPath func(lastIndex uint64, lastTerm uint64) string + SnapshotRecoveryRequest func(req *SnapshotRecoveryRequest) *SnapshotRecoveryResponse + Start func() error + State func() string + StateMachine func() StateMachine + Stop func() + TakeSnapshot func() error + Term func() uint64 + Transporter func() Transporter + VotedFor func() string + func NewServer(name string, path string, transporter Transporter, stateMachine StateMachine, ...) (Server, error) + type Snapshot struct + LastIndex uint64 + LastTerm uint64 + Path string + Peers []*Peer + State []byte + type SnapshotRecoveryRequest struct + LastIndex uint64 + LastTerm uint64 + LeaderName string + Peers []*Peer + State []byte + func (req *SnapshotRecoveryRequest) Decode(r io.Reader) (int, error) + func (req *SnapshotRecoveryRequest) Encode(w io.Writer) (int, error) + type SnapshotRecoveryResponse struct + CommitIndex uint64 + Success bool + Term uint64 + func (req *SnapshotRecoveryResponse) Decode(r io.Reader) (int, error) + func (req *SnapshotRecoveryResponse) Encode(w io.Writer) (int, error) + type SnapshotRequest struct + LastIndex uint64 + LastTerm uint64 + LeaderName string + func (req *SnapshotRequest) Decode(r io.Reader) (int, error) + func (req *SnapshotRequest) Encode(w io.Writer) (int, error) + type SnapshotResponse struct + Success bool + func (resp *SnapshotResponse) Decode(r io.Reader) (int, error) + func (resp *SnapshotResponse) Encode(w io.Writer) (int, error) + 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