raftfsm

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package raftfsm wires the single-group R3a committed-entry apply loop.

This package is intentionally narrow. It consumes already-committed deterministic CommandEntryV1 bytes, maps the Raft term/index directly to raftentry.ApplyEntryID, and delegates command execution to raftapply. It does not provide leader routing, failover, production snapshot storage, log truncation, read-index, or client-visible raft_committed semantics. Snapshot helpers here are limited to manifest export/verification around already-local logical state.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorCodeOf

func ErrorCodeOf(err error) (raftentry.DeterministicErrorCodeV1, bool)

Types

type CommittedEntryV1

type CommittedEntryV1 struct {
	Type  EntryTypeV1
	Term  uint64
	Index uint64
	Bytes []byte

	// CurrentCatalogVersion is the caller-observed local catalog version for
	// deterministic catalog guards. Missing guard context is left missing so
	// raftapply can fail closed before a visible mutation.
	CurrentCatalogVersion    uint64
	HasCurrentCatalogVersion bool
	SyncLocalCommandWAL      bool
	RequestMetadata          raftentry.RequestMetadataV1
	ExpectedTarget           *raftentry.TargetIdentityV1
}

CommittedEntryV1 is the deterministic payload delivered by the single-group Raft log after commitment.

type EntryTypeV1

type EntryTypeV1 string
const (
	EntryTypeCommandEntryV1 EntryTypeV1 = "command-entry-v1"
)

type Error

type Error struct {
	Code raftentry.DeterministicErrorCodeV1
	Err  error
}

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

type FSM

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

FSM applies committed deterministic entries to one local DB.

func Open

func Open(opts Options) (*FSM, error)

Open creates the durable progress/result stores for one single-group FSM.

func (*FSM) AllowsInitialIndexGapV1

func (f *FSM) AllowsInitialIndexGapV1() bool

func (*FSM) AppliedProgress

func (f *FSM) AppliedProgress(ctx context.Context) (raftcluster.AppliedProgress, error)

func (*FSM) ApplyCommittedCommandEntryV1

func (f *FSM) ApplyCommittedCommandEntryV1(ctx context.Context, entry raftcluster.CommittedCommandEntryV1) (raftentry.ApplyResultV1, error)

ApplyCommittedCommandEntryV1 adapts the raftcluster provider-delivered committed command shape into the local FSM committed-entry shape.

func (*FSM) ApplyCommittedEntriesV1

func (f *FSM) ApplyCommittedEntriesV1(entries []CommittedEntryV1) ([]raftentry.ApplyResultV1, error)

ApplyCommittedEntriesV1 applies entries in caller order and stops at the first fail-closed rejection.

func (*FSM) ApplyCommittedEntryV1

func (f *FSM) ApplyCommittedEntryV1(entry CommittedEntryV1) (raftentry.ApplyResultV1, error)

func (*FSM) Close

func (f *FSM) Close() error

func (*FSM) ExportSnapshotManifestV1

func (f *FSM) ExportSnapshotManifestV1(opts SnapshotManifestExportOptionsV1) (raftcluster.SnapshotManifestV1, error)

ExportSnapshotManifestV1 builds a metadata-only snapshot manifest for the current durable FSM apply point. It does not copy snapshot files, install state, replay log tails, truncate Raft logs, rejoin nodes, or claim that the exported metadata can serve reads.

func (*FSM) LastApplied

func (f *FSM) LastApplied() (raftentry.ApplyEntryID, bool)

func (*FSM) LogicalDigestV1

func (f *FSM) LogicalDigestV1(opts raftapply.LogicalDigestOptionsV1) (raftapply.LogicalDigestV1, error)

func (*FSM) PreflightCommandEntryV1

PreflightCommandEntryV1 adapts the raftcluster pre-commit deterministic preflight request into the local FSM apply preflight shape.

func (*FSM) RecoveryStatusV1

func (f *FSM) RecoveryStatusV1(ctx context.Context, opts RecoveryStatusOptionsV1) (raftcluster.RecoveryStatusV1, error)

RecoveryStatusV1 derives local recovery readiness from durable FSM state. It is a report-only status path: it does not install snapshots, replay tails, truncate logs, rejoin nodes, or prove production snapshot transfer.

func (*FSM) ValidateAppliedPrefixV1

func (f *FSM) ValidateAppliedPrefixV1(entries []CommittedEntryV1) (raftentry.ApplyResultV1, error)

func (*FSM) VerifyInstalledSnapshotManifestV1

func (f *FSM) VerifyInstalledSnapshotManifestV1(manifest raftcluster.SnapshotManifestV1) error

VerifyInstalledSnapshotManifestV1 verifies that this FSM already contains the exact logical state described by manifest. It does not copy snapshot bytes, truncate logs, or make the node safe to serve reads.

func (*FSM) WaitAppliedIndex

type Options

type Options struct {
	DB      *backenddb.DB
	Cluster raftcluster.Config

	DecodeLimits nativewire.Limits
	StoreOptions raftapply.DurableApplyStoreOptions

	ScopeRule     raftentry.ScopeRuleV1
	DatabaseScope string
	CatalogScope  string
}

Options configures one local single-group FSM instance.

type RecoveryStatusOptionsV1

type RecoveryStatusOptionsV1 struct {
	SnapshotManifest *raftcluster.SnapshotManifestV1
	TailTargetIndex  uint64

	RequireReadSafety bool
	ReadBarrier       raftcluster.AppliedIndexReadBarrier
}

type SnapshotManifestExportOptionsV1

type SnapshotManifestExportOptionsV1 struct {
	CreatedAt time.Time
}

Jump to

Keyboard shortcuts

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