raft

package
v3.0.6+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2022 License: AGPL-3.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClusterFromService

func NewClusterFromService(lg *zap.Logger, service string) *membership.RaftCluster

func NewConfig

func NewConfig() configx.Entrypoint

func NewRaftNode

func NewRaftNode(id int, name string, address string, service string, join bool, getSnapshot func() ([]byte, error), proposeC <-chan string,
	confChangeC <-chan raftpb.ConfChange) (<-chan *commit, <-chan error, <-chan *snap.Snapshotter)

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.

Types

type KV

type KV struct {
	Key string
	Val interface{}
}

type KVStore

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

a key-value store backed by raft

func NewKVStore

func NewKVStore(store configx.Values, snapshotter *snap.Snapshotter, proposeC chan<- string, commitC <-chan *commit, 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 interface{})

type Transporter

type Transporter interface {
	AddPeer(types.ID, []string)
	RemovePeer(types.ID)
	Send([]raftpb.Message)
	Start() error
	Stop()
	ErrorC() chan error
	Handler() http.Handler
}

Jump to

Keyboard shortcuts

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