raft

package
v0.0.0-...-60ae506 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 12, 2019 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package raft implements the write-ahead log, snapshotting, and peer management for the algorithm.

Index

Constants

This section is empty.

Variables

View Source
var Log = log.New(os.Stdout, "wagoraft: ", 0)

Log is the log to use for wagoraft

View Source
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

Types

type Status

type Status struct {
	ID              types.ID // this node's ID in the cluster
	Nodes           []uint64 // an array of all the node IDs
	ActiveNodeCount int      // the number of active nodes
	ActiveNodes     []uint64
}

Status provides information about the current state of the raft cluster.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL