lib

package
v0.3.19 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2022 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	State     raftInfoEntryType = 1
	Entry     raftInfoEntryType = 2
	Bootstrap raftInfoEntryType = 3
	Snapshot  raftInfoEntryType = 4
)

Variables

View Source
var MaxLogEntries = uint64(10_000)

Functions

This section is empty.

Types

type ControlPane

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

func NewControlPane

func NewControlPane(raft *RaftServer) *ControlPane

func (*ControlPane) Run

func (c *ControlPane) Run(addr string) error

type RaftServer

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

func NewRaftServer

func NewRaftServer(
	bindAddress string,
	nodeID uint64,
	metaPath string,
	database *db.SqliteStreamDB,
) *RaftServer

func (*RaftServer) AddNode

func (r *RaftServer) AddNode(peerID uint64, address string, clusterIDs ...uint64) error

func (*RaftServer) BindCluster

func (r *RaftServer) BindCluster(initMembers string, join bool, clusterIDs ...uint64) error

func (*RaftServer) GetActiveClusters

func (r *RaftServer) GetActiveClusters() []uint64

func (*RaftServer) GetClusterMap

func (r *RaftServer) GetClusterMap() map[uint64]uint64

func (*RaftServer) GetNodeMap

func (r *RaftServer) GetNodeMap() map[uint64][]uint64

func (*RaftServer) GetSnapshotStateMachine added in v0.3.18

func (r *RaftServer) GetSnapshotStateMachine() *SQLiteStateMachine

func (*RaftServer) Init

func (r *RaftServer) Init() error

func (*RaftServer) LeaderUpdated

func (r *RaftServer) LeaderUpdated(info raftio.LeaderInfo)

func (*RaftServer) Propose

func (r *RaftServer) Propose(key uint64, data []byte, dur time.Duration) (*dragonboat.RequestResult, error)

func (*RaftServer) RequestSnapshot

func (r *RaftServer) RequestSnapshot(timeout time.Duration) (uint64, uint64, error)

func (*RaftServer) ShuffleCluster

func (r *RaftServer) ShuffleCluster(nodes ...uint64) error

func (*RaftServer) TransferClusters

func (r *RaftServer) TransferClusters(toPeerID uint64, clusterIDs ...uint64) error

type ReplicationEvent

type ReplicationEvent[T any] struct {
	FromNodeId uint64
	Payload    *T
}

func (*ReplicationEvent[T]) Marshal

func (e *ReplicationEvent[T]) Marshal() ([]byte, error)

func (*ReplicationEvent[T]) Unmarshal

func (e *ReplicationEvent[T]) Unmarshal(data []byte) error

type SQLiteLogDB

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

func (*SQLiteLogDB) BinaryFormat

func (s *SQLiteLogDB) BinaryFormat() uint32

func (*SQLiteLogDB) Close

func (s *SQLiteLogDB) Close()

func (*SQLiteLogDB) CompactEntriesTo

func (s *SQLiteLogDB) CompactEntriesTo(clusterID uint64, nodeID uint64, index uint64) (<-chan struct{}, error)

func (*SQLiteLogDB) DeleteSnapshot

func (s *SQLiteLogDB) DeleteSnapshot(clusterID uint64, nodeID uint64, index uint64) error

func (*SQLiteLogDB) GetBootstrapInfo

func (s *SQLiteLogDB) GetBootstrapInfo(clusterID uint64, nodeID uint64) (raftpb.Bootstrap, error)

func (*SQLiteLogDB) ImportSnapshot

func (s *SQLiteLogDB) ImportSnapshot(snp raftpb.Snapshot, nodeID uint64) error

func (*SQLiteLogDB) IterateEntries

func (s *SQLiteLogDB) IterateEntries(
	entries []raftpb.Entry,
	size uint64,
	clusterID uint64,
	nodeID uint64,
	low uint64,
	high uint64,
	maxSize uint64,
) ([]raftpb.Entry, uint64, error)

IterateEntries returns the continuous Raft log entries of the specified Raft node between the index value range of [low, high) up to a max size limit of maxSize bytes. It returns the located log entries, their total size in bytes and the occurred error.

func (*SQLiteLogDB) ListNodeInfo

func (s *SQLiteLogDB) ListNodeInfo() ([]raftio.NodeInfo, error)

ListNodeInfo lists all available NodeInfo found in the log DB.

func (*SQLiteLogDB) ListSnapshots

func (s *SQLiteLogDB) ListSnapshots(clusterID uint64, nodeID uint64, index uint64) ([]raftpb.Snapshot, error)

func (*SQLiteLogDB) Name

func (s *SQLiteLogDB) Name() string

func (*SQLiteLogDB) ReadRaftState

func (s *SQLiteLogDB) ReadRaftState(clusterID uint64, nodeID uint64, snapshotIndex uint64) (raftio.RaftState, error)

func (*SQLiteLogDB) RemoveEntriesTo

func (s *SQLiteLogDB) RemoveEntriesTo(clusterID uint64, nodeID uint64, index uint64) error

RemoveEntriesTo removes entries associated with the specified Raft node up to the specified index.

func (*SQLiteLogDB) RemoveNodeData

func (s *SQLiteLogDB) RemoveNodeData(clusterID uint64, nodeID uint64) error

func (*SQLiteLogDB) SaveBootstrapInfo

func (s *SQLiteLogDB) SaveBootstrapInfo(clusterID uint64, nodeID uint64, bootstrap raftpb.Bootstrap) error

func (*SQLiteLogDB) SaveRaftState

func (s *SQLiteLogDB) SaveRaftState(updates []raftpb.Update, _ uint64) error

func (*SQLiteLogDB) SaveSnapshots

func (s *SQLiteLogDB) SaveSnapshots(updates []raftpb.Update) error

type SQLiteLogDBFactory

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

func NewSQLiteLogDBFactory

func NewSQLiteLogDBFactory(metaPath string, nodeID uint64) *SQLiteLogDBFactory

func (*SQLiteLogDBFactory) Create

func (*SQLiteLogDBFactory) Name

func (f *SQLiteLogDBFactory) Name() string

type SQLiteStateMachine

type SQLiteStateMachine struct {
	NodeID    uint64
	ClusterID uint64
	DB        *db.SqliteStreamDB
	RaftPath  string
	// contains filtered or unexported fields
}

func NewDBStateMachine

func NewDBStateMachine(
	clusterID, nodeID uint64,
	db *db.SqliteStreamDB,
	path string,
	enableSnapshots bool,
) *SQLiteStateMachine

func (*SQLiteStateMachine) Close

func (ssm *SQLiteStateMachine) Close() error

func (*SQLiteStateMachine) HasRestoredSnapshot

func (ssm *SQLiteStateMachine) HasRestoredSnapshot() bool

func (*SQLiteStateMachine) HasSavedSnapshot

func (ssm *SQLiteStateMachine) HasSavedSnapshot() bool

func (*SQLiteStateMachine) IsSnapshotEnabled added in v0.3.18

func (ssm *SQLiteStateMachine) IsSnapshotEnabled() bool

func (*SQLiteStateMachine) Lookup

func (ssm *SQLiteStateMachine) Lookup(_ interface{}) (interface{}, error)

func (*SQLiteStateMachine) Open

func (ssm *SQLiteStateMachine) Open(_ <-chan struct{}) (uint64, error)

func (*SQLiteStateMachine) PrepareSnapshot

func (ssm *SQLiteStateMachine) PrepareSnapshot() (interface{}, error)

func (*SQLiteStateMachine) RecoverFromSnapshot

func (ssm *SQLiteStateMachine) RecoverFromSnapshot(reader io.Reader, _ <-chan struct{}) error

func (*SQLiteStateMachine) SaveSnapshot

func (ssm *SQLiteStateMachine) SaveSnapshot(st interface{}, writer io.Writer, _ <-chan struct{}) error

func (*SQLiteStateMachine) Sync

func (ssm *SQLiteStateMachine) Sync() error

func (*SQLiteStateMachine) Update

func (ssm *SQLiteStateMachine) Update(entries []sm.Entry) ([]sm.Entry, error)

Jump to

Keyboard shortcuts

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