raft

package
v0.0.0-...-e27656c Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2020 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ServeHttpKVAPI

func ServeHttpKVAPI(kv *KvStore, port int, confChangeC chan<- raftpb.ConfChange, errorC <-chan error)

ServeHttpKVAPI starts a key-value server with a GET/PUT API and listens.

Types

type KvStore

type KvStore struct {
	// contains filtered or unexported fields
}

a key-value store backed by raft

func NewKVStore

func NewKVStore(snapshotter *snap.Snapshotter, proposeC chan<- string, commitC <-chan *string, errorC <-chan error) *KvStore

func (*KvStore) GetSnapshot

func (s *KvStore) GetSnapshot() ([]byte, error)

func (*KvStore) Lookup

func (s *KvStore) Lookup(key string) (string, bool)

func (*KvStore) Propose

func (s *KvStore) Propose(k string, v string)

type RaftNode

type RaftNode struct {

	// raft backing for the commit/error channel
	Node raft.Node
	// contains filtered or unexported fields
}

RaftNode is a key-value stream backed by raft

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, *RaftNode)

NewRaftNode initiates a raft instance and returns a committed log entry channel and error channel. Proposals for log updates are sent over the provided the 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.

func (*RaftNode) IsIDRemoved

func (rc *RaftNode) IsIDRemoved(id uint64) bool

IsIDRemoved is a function

func (*RaftNode) Process

func (rc *RaftNode) Process(ctx context.Context, m raftpb.Message) error

Process is a function

func (*RaftNode) ReportSnapshot

func (rc *RaftNode) ReportSnapshot(id uint64, status raft.SnapshotStatus)

ReportSnapshot is a function

func (*RaftNode) ReportUnreachable

func (rc *RaftNode) ReportUnreachable(id uint64)

ReportUnreachable is a function

Jump to

Keyboard shortcuts

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