fsm

package
v0.17.1 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package fsm implements the Raft FSM.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalLogEntry

func MarshalLogEntry(logEntry *v1.RaftLogEntry) ([]byte, error)

MarshalLogEntry marshals a RaftLogEntry.

func UnmarshalLogEntry

func UnmarshalLogEntry(data []byte) (*v1.RaftLogEntry, error)

UnmarshalLogEntry unmarshals a RaftLogEntry.

Types

type Options

type Options struct {
	// ApplyTimeout is the timeout for applying a log entry.
	ApplyTimeout time.Duration
}

Options are options for the FSM.

type RaftFSM

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

RaftFSM is the Raft FSM.

func New

func New(ctx context.Context, st storage.DualStorage, opts Options) *RaftFSM

New returns a new RaftFSM. The storage interface must be a direct connection to the underlying database.

func (*RaftFSM) Apply

func (r *RaftFSM) Apply(l *raft.Log) any

Apply applies a Raft log entry to the store.

func (*RaftFSM) ApplyBatch

func (r *RaftFSM) ApplyBatch(logs []*raft.Log) []any

ApplyBatch implements the raft.BatchingFSM interface.

func (*RaftFSM) CurrentTerm

func (r *RaftFSM) CurrentTerm() uint64

CurrentTerm returns the current term.

func (*RaftFSM) LastAppliedIndex

func (r *RaftFSM) LastAppliedIndex() uint64

LastAppliedIndex returns the last applied index.

func (*RaftFSM) Restore

func (r *RaftFSM) Restore(rdr io.ReadCloser) error

Restore restores a Raft snapshot.

func (*RaftFSM) Snapshot

func (r *RaftFSM) Snapshot() (raft.FSMSnapshot, error)

Snapshot returns a Raft snapshot.

Jump to

Keyboard shortcuts

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