Documentation ¶
Overview ¶
Package raft implements the write-ahead log, snapshotting, and peer management for the algorithm.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Log = log.New(os.Stdout, "wagoraft: ", 0)
Log is the log to use for wagoraft
var ZapLog = zap.NewExample()
ZapLog is the log to use with etcdraft
Functions ¶
func NewRaftNode ¶
func NewRaftNode(id int, peers []string, join bool, getSnapshot func() ([]byte, error), proposeC <-chan string, confChangeC <-chan raftpb.ConfChange) (<-chan *string, <-chan error, <-chan *snap.Snapshotter, func() (Status, error))
NewRaftNode initiates a raft instance and returns a committed log entry channel and error channel. Proposals for log updates are sent over the provided proposal channel. All log entries are replayed over the commit channel, followed by a nil message (to indicate the channel is current), then new log entries. To shutdown, close proposeC and read errorC.
param id: A unique number for this node param peers: A list of of the node's peers param join: Whether the node is joining an existing cluster param getSnapshot: A function to retrieve a representation of the current state machine param proposeC: A channel through which node propose changes to the state machine param confChangeC: A channel through which nodes propose cluster config changes returns: A 3-tuple with
- A channel for the committed proposals
- A channel for errors
- A channel to signal when the snapshotter is ready