raft

package
v0.1.60 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2025 License: GPL-3.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Commit added in v0.0.57

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

type KVStore added in v0.0.57

type KVStore struct {
	DataC       chan KV.KV
	Restore     []*KV.KV
	ConfChangeC chan raftpb.ConfChange

	Node *node.Node

	CommittedKeys sync.Map
	// contains filtered or unexported fields
}

a key-value store backed by raft

func NewKVStore added in v0.0.57

func NewKVStore(etcdclient *clientv3.Client, snapshotter *snap.Snapshotter, channels *channels.Cluster, commitC <-chan *Commit, errorC <-chan error, dataC chan KV.KV, node *node.Node, replay bool) (*KVStore, error)

func (*KVStore) Close added in v0.1.56

func (s *KVStore) Close() error

func (*KVStore) GetSnapshot added in v0.0.57

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

func (*KVStore) Propose added in v0.0.57

func (s *KVStore) Propose(k string, v []byte, node uint64)

type RaftNode added in v0.0.57

type RaftNode struct {
	Peers *node.Nodes // raft peer URLs

	IsLeader atomic.Bool

	TLSConfig *tls.Config
	// contains filtered or unexported fields
}

func NewRaftNode added in v0.0.57

func NewRaftNode(
	keys *keys.Keys,
	TLSConfig *tls.Config,
	id uint64,
	peers *node.Nodes,
	join bool,
	replay bool,
	getSnapshot func() ([]byte, error),
	channels *channels.Cluster,
	config *configuration.RaftConfiguration,
) (*RaftNode, <-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.

func (*RaftNode) Done added in v0.1.42

func (rc *RaftNode) Done() <-chan struct{}

func (*RaftNode) ForceSnapshot added in v0.1.56

func (rc *RaftNode) ForceSnapshot() error

func (*RaftNode) GetMemoryStats added in v0.1.58

func (rc *RaftNode) GetMemoryStats() (map[string]interface{}, error)

func (*RaftNode) GetWALSize added in v0.1.56

func (rc *RaftNode) GetWALSize() (int64, error)

func (*RaftNode) IsIDRemoved added in v0.0.57

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

func (*RaftNode) OnLeadershipChange added in v0.1.56

func (rc *RaftNode) OnLeadershipChange(isLeader bool)

func (*RaftNode) Process added in v0.0.57

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

func (*RaftNode) ReportSnapshot added in v0.0.57

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

func (*RaftNode) ReportUnreachable added in v0.0.57

func (rc *RaftNode) ReportUnreachable(id uint64)

func (*RaftNode) TransferLeadership added in v0.1.42

func (rc *RaftNode) TransferLeadership(ctx context.Context, nodeID uint64)

Jump to

Keyboard shortcuts

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