Documentation
¶
Overview ¶
Package raftcluster defines the single-group Raft cluster boundary for TreeDB.
This package owns the configuration/storage layout contract plus the first single-group submit/apply bridge. It does not start a consensus loop, choose a Raft library, install snapshots, truncate logs, or route multiple groups. AckRaftCommitted is only satisfied when a commit source provides explicit production-consensus evidence and the local committed-entry applier reports recoverable local coverage.
The local TreeDB command WAL remains node-local crash-recovery state. It is not a Raft log. Commit sources may append deterministic command entries to a Raft log and then apply committed entries through R3a, but the application of a committed entry is serialized by this single-group bridge and still has to satisfy TreeDB's local command-WAL recoverability rules before the node reports raft-committed durability.
The TreeDB value log under maindb/value_vlog is persistent value storage. Raft storage must not treat value_vlog segments as temporary WAL bytes or delete them by age. Value-log segments are managed by reachability-based GC and rewrite/compaction, independent of the consensus log.
Index ¶
- Constants
- Variables
- func CommandWALDir(dir string) string
- func DefaultClusterDir(dir string) string
- func EncodeSnapshotManifestV1(manifest SnapshotManifestV1) ([]byte, error)
- func LeafLogDir(dir string) string
- func MainDBDir(dir string) string
- func ValueLogDir(dir string) string
- type AdmissionProvider
- type AdmissionStatus
- type AppliedIndexReadBarrier
- type AppliedIndexReadBarrierWaiter
- type AppliedProgress
- type AppliedProgressReader
- type CatalogVersionProvider
- type CatalogVersionProviderFunc
- type CommandEntryPreflightFunc
- type CommandEntryPreflightRequestV1
- type CommandEntryPreflightResultV1
- type CommandEntryPreflightV1
- type CommitCommandEntryV1Request
- type CommitCommandEntryV1Result
- type CommitEvidenceKindV1
- type CommitEvidenceV1
- type CommitSource
- type CommitSourceFunc
- type CommittedCommandApplierFunc
- type CommittedCommandApplierV1
- type CommittedCommandEntryV1
- type Config
- type FeatureName
- type FeatureSet
- type GroupID
- type HashicorpRaftProvider
- func (p *HashicorpRaftProvider) Close() error
- func (p *HashicorpRaftProvider) ClusterAdmissionStatus(ctx context.Context) (AdmissionStatus, error)
- func (p *HashicorpRaftProvider) CommitCommandEntryV1(ctx context.Context, req CommitCommandEntryV1Request) (CommitCommandEntryV1Result, error)
- func (p *HashicorpRaftProvider) Config() ResolvedConfig
- type HashicorpRaftProviderOptions
- type InitialIndexGapSupportV1
- type NodeID
- type Peer
- type PeerStorageDir
- type Provider
- type ProviderFactory
- type ReadIndexBarrier
- type ReadIndexCheckOptions
- type ReadIndexEvidenceKind
- type ReadIndexProof
- type ReadIndexProvider
- type RecoveryMetricKeyV1
- type RecoveryMetricSampleV1
- type RecoveryMetricsV1
- type RecoveryReadSafetyStateV1
- type RecoveryReadinessV1
- type RecoverySnapshotStateV1
- type RecoveryStatusV1
- type RecoveryTailStateV1
- type RecoveryUnsupportedOperationV1
- type RequiredFeature
- type ResolvedConfig
- type SequencedCommitSource
- type SequencedCommitSourceOptions
- type SingleGroupSubmitter
- func (s *SingleGroupSubmitter) ClusterAdmissionStatus(ctx context.Context) (AdmissionStatus, error)
- func (s *SingleGroupSubmitter) Config() ResolvedConfig
- func (s *SingleGroupSubmitter) SubmitCommandEntryV1(ctx context.Context, entry []byte, metadata raftentry.RequestMetadataV1) (SubmitResultV1, error)
- type SingleGroupSubmitterOptions
- type SnapshotManifestV1
- type SnapshotScopeIdentityV1
- type StaticAdmissionProvider
- type StorageLayout
- type SubmitResultV1
- type Version
Examples ¶
Constants ¶
const ( RecoveryStatusFormatV1 = "treedb.raftcluster.recovery-status" RecoveryStatusVersion1 = uint16(1) RecoveryMetricsFormatV1 = "treedb.raftcluster.recovery-metrics" RecoveryMetricsVersion1 = uint16(1) )
const ( SnapshotManifestFormatV1 = "treedb.raftcluster.snapshot-manifest" SnapshotManifestVersion1 = uint16(1) )
Variables ¶
var ( SupportedConfigVersion = Version{Major: 1, Minor: 0} SupportedFeatureFloors = map[FeatureName]Version{ FeatureSingleGroupProvider: {Major: 1, Minor: 0}, } ErrInvalidConfig = errors.New("raftcluster: invalid config") ErrMissingNodeID = errors.New("raftcluster: missing node id") ErrMissingGroupID = errors.New("raftcluster: missing group id") ErrMissingPeer = errors.New("raftcluster: missing peer") ErrDuplicatePeer = errors.New("raftcluster: duplicate peer") ErrLocalMemberMissing = errors.New("raftcluster: local member missing") ErrInvalidStoragePath = errors.New("raftcluster: invalid storage path") ErrUnsupportedFeature = errors.New("raftcluster: unsupported feature") ErrUnsupportedVersion = errors.New("raftcluster: unsupported version") ErrUnsupportedProvider = errors.New("raftcluster: unsupported provider") )
var ( ErrInvalidHashicorpRaftProvider = errors.New("raftcluster: invalid hashicorp raft provider") ErrHashicorpRaftLogEntry = errors.New("raftcluster: invalid hashicorp raft log entry") ErrRaftSnapshotUnsupported = errors.New("raftcluster: raft snapshots unsupported") )
var ( ErrReadBarrierNotSatisfied = errors.New("raftcluster: read barrier not satisfied") ErrReadBarrierTargetMismatch = errors.New("raftcluster: read barrier target mismatch") )
var ( ErrInvalidSubmitter = errors.New("raftcluster: invalid submitter") ErrNotLeader = errors.New("raftcluster: not leader") ErrCommitAmbiguous = errors.New("raftcluster: commit ambiguous") ErrCommitNotProven = errors.New("raftcluster: commit not proven") ErrLocalApplyNotRecoverable = errors.New("raftcluster: local apply not recoverable") ErrInvalidCommittedEntry = errors.New("raftcluster: invalid committed entry") ErrUnsupportedSubmitAck = errors.New("raftcluster: unsupported submit ack") ErrMissingCatalogVersion = errors.New("raftcluster: missing catalog version") ErrCatalogVersionMismatch = errors.New("raftcluster: catalog version mismatch") ErrUnexpectedCommittedTarget = errors.New("raftcluster: committed target mismatch") ErrRouteGroupMismatch = errors.New("raftcluster: route group mismatch") )
var ErrInvalidSnapshotManifest = errors.New("raftcluster: invalid snapshot manifest")
var ErrRecoveryOperationUnsupported = errors.New("raftcluster: recovery operation unsupported")
Functions ¶
func CommandWALDir ¶
func DefaultClusterDir ¶
func EncodeSnapshotManifestV1 ¶
func EncodeSnapshotManifestV1(manifest SnapshotManifestV1) ([]byte, error)
func LeafLogDir ¶
func ValueLogDir ¶
Types ¶
type AdmissionProvider ¶
type AdmissionProvider interface {
ClusterAdmissionStatus(context.Context) (AdmissionStatus, error)
}
AdmissionProvider exposes the single-group write-admission state. Returning the zero AdmissionStatus fails closed as not-leader.
type AdmissionStatus ¶
AdmissionStatus reports whether this node may submit single-group writes.
func FollowerAdmission ¶
func FollowerAdmission(leaderHint NodeID, reason string) AdmissionStatus
func LeaderAdmission ¶
func LeaderAdmission() AdmissionStatus
func UnavailableAdmission ¶
func UnavailableAdmission(reason string) AdmissionStatus
type AppliedIndexReadBarrier ¶
AppliedIndexReadBarrier requests proof that a node has applied through at least MinAppliedIndex before a read observes local state.
func (AppliedIndexReadBarrier) Check ¶
func (b AppliedIndexReadBarrier) Check(progress AppliedProgress) error
func (AppliedIndexReadBarrier) SatisfiedBy ¶
func (b AppliedIndexReadBarrier) SatisfiedBy(progress AppliedProgress) bool
type AppliedIndexReadBarrierWaiter ¶
type AppliedIndexReadBarrierWaiter interface {
WaitAppliedIndex(context.Context, AppliedIndexReadBarrier) (AppliedProgress, error)
}
AppliedIndexReadBarrierWaiter waits until it can prove an applied-index read barrier or fails closed.
type AppliedProgress ¶
type AppliedProgress struct {
NodeID NodeID
GroupID GroupID
Term uint64
Index uint64
HasApplied bool
}
AppliedProgress is the local apply progress a node can prove before serving a read. It is intentionally an applied-index contract, not a Raft read-index or lease proof.
type AppliedProgressReader ¶
type AppliedProgressReader interface {
AppliedProgress(context.Context) (AppliedProgress, error)
}
AppliedProgressReader exposes current applied progress with errors.
type CatalogVersionProvider ¶
type CatalogVersionProvider interface {
CurrentCatalogVersion(context.Context) (version uint64, ok bool, err error)
}
CatalogVersionProvider returns the local catalog version used for deterministic catalog guards. ok=false fails closed before commit.
type CatalogVersionProviderFunc ¶
func (CatalogVersionProviderFunc) CurrentCatalogVersion ¶
type CommandEntryPreflightFunc ¶
type CommandEntryPreflightFunc func(context.Context, CommandEntryPreflightRequestV1) (CommandEntryPreflightResultV1, error)
func (CommandEntryPreflightFunc) PreflightCommandEntryV1 ¶
func (f CommandEntryPreflightFunc) PreflightCommandEntryV1(ctx context.Context, req CommandEntryPreflightRequestV1) (CommandEntryPreflightResultV1, error)
type CommandEntryPreflightRequestV1 ¶
type CommandEntryPreflightRequestV1 struct {
GroupID GroupID
NodeID NodeID
EntryBytes []byte
DecodedEntry raftentry.CommandEntryV1
CurrentCatalogVersion uint64
HasCurrentCatalogVersion bool
SyncLocalCommandWAL bool
RequestMetadata raftentry.RequestMetadataV1
ExpectedTarget *raftentry.TargetIdentityV1
}
CommandEntryPreflightRequestV1 asks the local deterministic apply provider to reject commands that cannot apply against the current local catalog and collection state before the commit source assigns a Raft log identity.
func (CommandEntryPreflightRequestV1) Clone ¶
func (r CommandEntryPreflightRequestV1) Clone() CommandEntryPreflightRequestV1
type CommandEntryPreflightResultV1 ¶
type CommandEntryPreflightResultV1 struct {
KnownIdempotencyReplay bool
}
type CommandEntryPreflightV1 ¶
type CommandEntryPreflightV1 interface {
PreflightCommandEntryV1(context.Context, CommandEntryPreflightRequestV1) (CommandEntryPreflightResultV1, error)
}
CommandEntryPreflightV1 validates deterministic/catalog apply acceptability before the entry is admitted to the commit source. Implementations must treat the request as read-only and clone any data retained after return.
type CommitCommandEntryV1Request ¶
type CommitCommandEntryV1Request struct {
GroupID GroupID
NodeID NodeID
EntryBytes []byte
CurrentCatalogVersion uint64
HasCurrentCatalogVersion bool
SyncLocalCommandWAL bool
RequestMetadata raftentry.RequestMetadataV1
ExpectedTarget *raftentry.TargetIdentityV1
}
CommitCommandEntryV1Request is the provider boundary between submit admission and a concrete single-group commit source. The entry bytes are the deterministic native-wire CommandEntryV1 payload already validated by the submitter.
func (CommitCommandEntryV1Request) Clone ¶
func (r CommitCommandEntryV1Request) Clone() CommitCommandEntryV1Request
type CommitCommandEntryV1Result ¶
type CommitCommandEntryV1Result struct {
Entry CommittedCommandEntryV1
Evidence CommitEvidenceV1
}
type CommitEvidenceKindV1 ¶
type CommitEvidenceKindV1 string
const ( // CommitEvidenceProductionConsensusV1 is the only evidence kind that may // satisfy AckRaftCommitted. The selected consensus adapter is responsible // for setting ProductionConsensus=true only after quorum commitment. CommitEvidenceProductionConsensusV1 CommitEvidenceKindV1 = "production-consensus-v1" // CommitEvidenceDeterministicHarnessV1 records deterministic local/test // commit ordering. It never proves production quorum commitment. CommitEvidenceDeterministicHarnessV1 CommitEvidenceKindV1 = "deterministic-harness-v1" )
type CommitEvidenceV1 ¶
type CommitEvidenceV1 struct {
Kind CommitEvidenceKindV1
GroupID GroupID
NodeID NodeID
LeaderID NodeID
Term uint64
Index uint64
Committed bool
ProductionConsensus bool
}
func (CommitEvidenceV1) EntryID ¶
func (e CommitEvidenceV1) EntryID() raftentry.ApplyEntryID
func (CommitEvidenceV1) ProvesProductionConsensus ¶
func (e CommitEvidenceV1) ProvesProductionConsensus() bool
type CommitSource ¶
type CommitSource interface {
CommitCommandEntryV1(context.Context, CommitCommandEntryV1Request) (CommitCommandEntryV1Result, error)
}
CommitSource commits deterministic command entries and returns the committed log identity plus evidence. A test/harness source may implement this interface, but only production-consensus evidence can satisfy raft_committed.
type CommitSourceFunc ¶
type CommitSourceFunc func(context.Context, CommitCommandEntryV1Request) (CommitCommandEntryV1Result, error)
func (CommitSourceFunc) CommitCommandEntryV1 ¶
func (f CommitSourceFunc) CommitCommandEntryV1(ctx context.Context, req CommitCommandEntryV1Request) (CommitCommandEntryV1Result, error)
type CommittedCommandApplierFunc ¶
type CommittedCommandApplierFunc func(context.Context, CommittedCommandEntryV1) (raftentry.ApplyResultV1, error)
func (CommittedCommandApplierFunc) ApplyCommittedCommandEntryV1 ¶
func (f CommittedCommandApplierFunc) ApplyCommittedCommandEntryV1(ctx context.Context, entry CommittedCommandEntryV1) (raftentry.ApplyResultV1, error)
type CommittedCommandApplierV1 ¶
type CommittedCommandApplierV1 interface {
ApplyCommittedCommandEntryV1(context.Context, CommittedCommandEntryV1) (raftentry.ApplyResultV1, error)
}
CommittedCommandApplierV1 is implemented by the local raftfsm adapter.
type CommittedCommandEntryV1 ¶
type CommittedCommandEntryV1 struct {
Term uint64
Index uint64
Bytes []byte
CurrentCatalogVersion uint64
HasCurrentCatalogVersion bool
SyncLocalCommandWAL bool
RequestMetadata raftentry.RequestMetadataV1
ExpectedTarget *raftentry.TargetIdentityV1
}
CommittedCommandEntryV1 is a deterministic command entry after the single-group commit source has assigned a Raft log identity.
func (CommittedCommandEntryV1) Clone ¶
func (e CommittedCommandEntryV1) Clone() CommittedCommandEntryV1
func (CommittedCommandEntryV1) EntryID ¶
func (e CommittedCommandEntryV1) EntryID() raftentry.ApplyEntryID
type Config ¶
type Config struct {
Dir string
ClusterDir string
DisableSideStores bool
NodeID NodeID
GroupID GroupID
Peers []Peer
Features FeatureSet
}
Config is the user-provided single-group cluster configuration.
Dir is the TreeDB Options.Dir value. ClusterDir optionally overrides the default raftcluster directory. Even with an explicit ClusterDir, Dir is required so validation can reject layouts that overlap the resolved TreeDB main DB, WAL, value_vlog, or leaf_vlog paths.
type FeatureName ¶
type FeatureName string
const ( // FeatureSingleGroupProvider is the feature gate for the #3044-0 provider // and storage boundary. It reserves only the single-group contract; it does // not imply a selected Raft library or production HA behavior. FeatureSingleGroupProvider FeatureName = "treedb.raftcluster.single_group_provider" )
type FeatureSet ¶
type FeatureSet struct {
ConfigVersion Version
Required []RequiredFeature
}
FeatureSet carries the config format and feature floor required by this package. A zero value is normalized to the current single-group provider v1 floor.
func DefaultFeatureSet ¶
func DefaultFeatureSet() FeatureSet
type HashicorpRaftProvider ¶
type HashicorpRaftProvider struct {
// contains filtered or unexported fields
}
HashicorpRaftProvider implements AdmissionProvider and CommitSource on top of github.com/hashicorp/raft for one TreeDB Raft group.
func OpenHashicorpRaftProvider ¶
func OpenHashicorpRaftProvider(opts HashicorpRaftProviderOptions) (*HashicorpRaftProvider, error)
func (*HashicorpRaftProvider) Close ¶
func (p *HashicorpRaftProvider) Close() error
func (*HashicorpRaftProvider) ClusterAdmissionStatus ¶
func (p *HashicorpRaftProvider) ClusterAdmissionStatus(ctx context.Context) (AdmissionStatus, error)
func (*HashicorpRaftProvider) CommitCommandEntryV1 ¶
func (p *HashicorpRaftProvider) CommitCommandEntryV1(ctx context.Context, req CommitCommandEntryV1Request) (CommitCommandEntryV1Result, error)
func (*HashicorpRaftProvider) Config ¶
func (p *HashicorpRaftProvider) Config() ResolvedConfig
type HashicorpRaftProviderOptions ¶
type HashicorpRaftProviderOptions struct {
Cluster Config
Applier CommittedCommandApplierV1
Transport hraft.Transport
RaftConfig *hraft.Config
LogStore hraft.LogStore
StableStore hraft.StableStore
SnapshotStore hraft.SnapshotStore
Bootstrap bool
ApplyTimeout time.Duration
SnapshotRetain int
// ApplyFailureHandler is invoked before the FSM returns a local apply error.
// Nil panics, which fails the Raft node closed so followers cannot advance
// their applied index past an unapplied TreeDB command.
ApplyFailureHandler func(error)
}
HashicorpRaftProviderOptions configures the first production single-group consensus adapter. The provider owns the log/stable stores it opens from the raftcluster storage layout; caller-supplied stores and transports remain caller-owned.
type InitialIndexGapSupportV1 ¶
type InitialIndexGapSupportV1 interface {
AllowsInitialIndexGapV1() bool
}
InitialIndexGapSupportV1 is implemented by durable appliers that can report whether their first applied Raft command may start above index 1.
type PeerStorageDir ¶
type Provider ¶
type Provider interface {
Config() ResolvedConfig
}
Provider is the shape future Raft library adapters expose to the rest of TreeDB. It intentionally exposes only identity and storage layout in this slice.
type ProviderFactory ¶
type ProviderFactory interface {
OpenProvider(context.Context, ResolvedConfig) (Provider, error)
}
ProviderFactory creates a provider from a validated single-group config. It is a factory boundary, not an admission or consensus API.
type ReadIndexBarrier ¶
ReadIndexBarrier requests a quorum-backed read-index proof for a node/group. Empty NodeID or GroupID fields do not constrain the proof target, but callers that know the intended target should set them so mismatches fail closed.
func (ReadIndexBarrier) Check ¶
func (b ReadIndexBarrier) Check(proof ReadIndexProof) error
func (ReadIndexBarrier) CheckWithOptions ¶
func (b ReadIndexBarrier) CheckWithOptions(proof ReadIndexProof, opts ReadIndexCheckOptions) error
func (ReadIndexBarrier) SatisfiedBy ¶
func (b ReadIndexBarrier) SatisfiedBy(proof ReadIndexProof) bool
type ReadIndexCheckOptions ¶
type ReadIndexCheckOptions struct {
AllowNonProductionEvidence bool
}
ReadIndexCheckOptions allows deterministic harnesses to validate target and quorum shape without pretending their evidence is production-consensus proof.
type ReadIndexEvidenceKind ¶
type ReadIndexEvidenceKind uint8
ReadIndexEvidenceKind records where a read-index proof came from. Production linearizable reads only accept ReadIndexEvidenceProduction.
const ( ReadIndexEvidenceUnknown ReadIndexEvidenceKind = iota ReadIndexEvidenceTestHarness ReadIndexEvidenceProduction )
func (ReadIndexEvidenceKind) String ¶
func (k ReadIndexEvidenceKind) String() string
type ReadIndexProof ¶
type ReadIndexProof struct {
NodeID NodeID
GroupID GroupID
Term uint64
Index uint64
HasQuorum bool
EvidenceKind ReadIndexEvidenceKind
}
ReadIndexProof is the minimal result a Raft adapter must provide before a linearizable local read can wait for local application. Production Raft adapters must set EvidenceKind to ReadIndexEvidenceProduction only after a real read-index or equivalent quorum proof. Harness and fake providers should use non-production evidence unless a narrow test deliberately exercises the production path.
func (ReadIndexProof) AppliedIndexBarrier ¶
func (p ReadIndexProof) AppliedIndexBarrier() AppliedIndexReadBarrier
type ReadIndexProvider ¶
type ReadIndexProvider interface {
ReadIndex(context.Context, ReadIndexBarrier) (ReadIndexProof, error)
}
ReadIndexProvider obtains a read-index proof from the selected Raft adapter.
type RecoveryMetricKeyV1 ¶
type RecoveryMetricKeyV1 string
const ( RecoveryMetricSafeToServeReadsV1 RecoveryMetricKeyV1 = "treedb.raftcluster.recovery.safe_to_serve_reads" RecoveryMetricAppliedIndexV1 RecoveryMetricKeyV1 = "treedb.raftcluster.recovery.applied_index" RecoveryMetricRequiredAppliedIndexV1 RecoveryMetricKeyV1 = "treedb.raftcluster.recovery.required_applied_index" RecoveryMetricSnapshotIncludedIndexV1 RecoveryMetricKeyV1 = "treedb.raftcluster.recovery.snapshot_last_included_index" RecoveryMetricTailTargetIndexV1 RecoveryMetricKeyV1 = "treedb.raftcluster.recovery.tail_target_index" RecoveryMetricTailLagEntriesV1 RecoveryMetricKeyV1 = "treedb.raftcluster.recovery.tail_lag_entries" RecoveryMetricAppliedCommandLSNV1 RecoveryMetricKeyV1 = "treedb.raftcluster.recovery.applied_command_lsn" )
type RecoveryMetricSampleV1 ¶
type RecoveryMetricSampleV1 struct {
Key RecoveryMetricKeyV1 `json:"key"`
Value uint64 `json:"value"`
}
type RecoveryMetricsV1 ¶
type RecoveryMetricsV1 struct {
Format string `json:"format"`
Version uint16 `json:"version"`
StatusLabel RecoveryReadinessV1 `json:"status_label"`
SnapshotLabel RecoverySnapshotStateV1 `json:"snapshot_label"`
TailLabel RecoveryTailStateV1 `json:"tail_label"`
ReadSafetyLabel RecoveryReadSafetyStateV1 `json:"read_safety_label"`
Samples []RecoveryMetricSampleV1 `json:"samples"`
}
RecoveryMetricsV1 freezes the metric keys and low-cardinality status labels exported by RecoveryStatusV1. Callers may map samples into their metrics backend, but should not derive new keys from error strings.
type RecoveryReadSafetyStateV1 ¶
type RecoveryReadSafetyStateV1 string
const ( RecoveryReadSafetyNotRequestedV1 RecoveryReadSafetyStateV1 = "not_requested" RecoveryReadSafetyAppliedIndexSatisfiedV1 RecoveryReadSafetyStateV1 = "applied_index_satisfied" RecoveryReadSafetyAppliedIndexLaggingV1 RecoveryReadSafetyStateV1 = "applied_index_lagging" RecoveryReadSafetyTargetMismatchV1 RecoveryReadSafetyStateV1 = "target_mismatch" )
type RecoveryReadinessV1 ¶
type RecoveryReadinessV1 string
const ( RecoveryReadinessUnsafeNoSnapshotV1 RecoveryReadinessV1 = "unsafe_no_snapshot" RecoveryReadinessUnsafeManifestUnverifiedV1 RecoveryReadinessV1 = "unsafe_manifest_unverified" RecoveryReadinessTailPendingV1 RecoveryReadinessV1 = "tail_pending" RecoveryReadinessTailCompleteV1 RecoveryReadinessV1 = "tail_complete" RecoveryReadinessReadSafetyPendingV1 RecoveryReadinessV1 = "read_safety_pending" RecoveryReadinessReadyAppliedIndexV1 RecoveryReadinessV1 = "ready_applied_index" RecoveryReadinessUnsupportedV1 RecoveryReadinessV1 = "unsupported" )
type RecoverySnapshotStateV1 ¶
type RecoverySnapshotStateV1 string
const ( RecoverySnapshotStateNoneV1 RecoverySnapshotStateV1 = "no_snapshot" RecoverySnapshotStateManifestVerifiedV1 RecoverySnapshotStateV1 = "manifest_verified" RecoverySnapshotStateManifestRejectedV1 RecoverySnapshotStateV1 = "manifest_rejected" )
type RecoveryStatusV1 ¶
type RecoveryStatusV1 struct {
Format string `json:"format"`
Version uint16 `json:"version"`
NodeID NodeID `json:"node_id"`
GroupID GroupID `json:"group_id"`
Readiness RecoveryReadinessV1 `json:"readiness"`
SafeToServeReads bool `json:"safe_to_serve_reads"`
SnapshotState RecoverySnapshotStateV1 `json:"snapshot_state"`
TailState RecoveryTailStateV1 `json:"tail_state"`
ReadSafetyState RecoveryReadSafetyStateV1 `json:"read_safety_state"`
Unsupported []RecoveryUnsupportedOperationV1 `json:"unsupported,omitempty"`
AppliedProgress AppliedProgress `json:"applied_progress"`
AppliedCommandLSN uint64 `json:"applied_command_lsn"`
HasAppliedCommandLSN bool `json:"has_applied_command_lsn"`
SnapshotManifest *SnapshotManifestV1 `json:"snapshot_manifest,omitempty"`
RequiredAppliedIndex uint64 `json:"required_applied_index"`
TailTargetIndex uint64 `json:"tail_target_index"`
TailLagEntries uint64 `json:"tail_lag_entries"`
Errors []string `json:"errors,omitempty"`
}
RecoveryStatusV1 is a report-only status contract. It describes whether a local node can prove snapshot/tail/read safety from durable local evidence; it does not install snapshots, truncate Raft logs, or rejoin replicas.
func NewRecoveryStatusV1 ¶
func NewRecoveryStatusV1(nodeID NodeID, groupID GroupID) RecoveryStatusV1
func UnsupportedRecoveryStatusV1 ¶
func UnsupportedRecoveryStatusV1(nodeID NodeID, groupID GroupID, operation RecoveryUnsupportedOperationV1) RecoveryStatusV1
func (RecoveryStatusV1) MetricsV1 ¶
func (s RecoveryStatusV1) MetricsV1() RecoveryMetricsV1
type RecoveryTailStateV1 ¶
type RecoveryTailStateV1 string
const ( RecoveryTailStateNoSnapshotV1 RecoveryTailStateV1 = "no_snapshot" RecoveryTailStatePendingV1 RecoveryTailStateV1 = "pending" RecoveryTailStateCompleteV1 RecoveryTailStateV1 = "complete" RecoveryTailStateUnknownV1 RecoveryTailStateV1 = "unknown" )
type RecoveryUnsupportedOperationV1 ¶
type RecoveryUnsupportedOperationV1 string
const ( RecoveryUnsupportedLogTruncationV1 RecoveryUnsupportedOperationV1 = "log_truncation" RecoveryUnsupportedProductionRejoinV1 RecoveryUnsupportedOperationV1 = "production_rejoin" RecoveryUnsupportedProductionSnapshotTransferV1 RecoveryUnsupportedOperationV1 = "production_snapshot_transfer" )
type RequiredFeature ¶
type RequiredFeature struct {
Name FeatureName
Version Version
}
RequiredFeature declares a cluster feature that must be understood before a node may open the provider boundary.
type ResolvedConfig ¶
type ResolvedConfig struct {
Dir string
ClusterDir string
NodeID NodeID
GroupID GroupID
Peers []Peer
Features FeatureSet
Layout StorageLayout
}
func Validate ¶
func Validate(cfg Config) (ResolvedConfig, error)
Example ¶
package main
import (
"fmt"
"path/filepath"
"github.com/snissn/gomap/TreeDB/internal/raftcluster"
)
func main() {
resolved, err := raftcluster.Validate(raftcluster.Config{
Dir: "/var/lib/treedb",
NodeID: "node-a",
GroupID: "default",
Peers: []raftcluster.Peer{
{ID: "node-a", Address: "10.0.0.1:9201"},
{ID: "node-b", Address: "10.0.0.2:9201"},
{ID: "node-c", Address: "10.0.0.3:9201"},
},
})
fmt.Println(err == nil)
fmt.Println(filepath.ToSlash(resolved.Layout.LogDir))
fmt.Println(filepath.ToSlash(resolved.Layout.StableDir))
fmt.Println(filepath.ToSlash(resolved.Layout.SnapshotDir))
}
Output: true /var/lib/treedb/raftcluster/nodes/node-a/groups/default/log /var/lib/treedb/raftcluster/nodes/node-a/groups/default/stable /var/lib/treedb/raftcluster/nodes/node-a/groups/default/snapshots
type SequencedCommitSource ¶
type SequencedCommitSource struct {
// contains filtered or unexported fields
}
SequencedCommitSource is a deterministic in-process CommitSource. By default it returns deterministic-harness evidence; ProductionConsensus must be set by a caller that is wrapping an actual quorum source or by tests that are explicitly exercising downstream raft_committed gates.
func NewSequencedCommitSource ¶
func NewSequencedCommitSource(opts SequencedCommitSourceOptions) *SequencedCommitSource
func (*SequencedCommitSource) CommitCommandEntryV1 ¶
func (s *SequencedCommitSource) CommitCommandEntryV1(ctx context.Context, req CommitCommandEntryV1Request) (CommitCommandEntryV1Result, error)
type SingleGroupSubmitter ¶
type SingleGroupSubmitter struct {
// contains filtered or unexported fields
}
func NewSingleGroupSubmitter ¶
func NewSingleGroupSubmitter(opts SingleGroupSubmitterOptions) (*SingleGroupSubmitter, error)
func (*SingleGroupSubmitter) ClusterAdmissionStatus ¶
func (s *SingleGroupSubmitter) ClusterAdmissionStatus(ctx context.Context) (AdmissionStatus, error)
func (*SingleGroupSubmitter) Config ¶
func (s *SingleGroupSubmitter) Config() ResolvedConfig
func (*SingleGroupSubmitter) SubmitCommandEntryV1 ¶
func (s *SingleGroupSubmitter) SubmitCommandEntryV1(ctx context.Context, entry []byte, metadata raftentry.RequestMetadataV1) (SubmitResultV1, error)
type SingleGroupSubmitterOptions ¶
type SingleGroupSubmitterOptions struct {
Cluster Config
AdmissionProvider AdmissionProvider
CommitSource CommitSource
Preflight CommandEntryPreflightV1
Applier CommittedCommandApplierV1
CatalogVersionProvider CatalogVersionProvider
DecodeLimits iwire.Limits
ScopeRule raftentry.ScopeRuleV1
DatabaseScope string
CatalogScope string
// DisableLocalCommandWALSync is for tests that intentionally model weaker
// local recovery. The default bridge syncs local command-WAL coverage before
// reporting CommittedRecoverable; when disabled, AckRaftCommitted is rejected.
DisableLocalCommandWALSync bool
}
type SnapshotManifestV1 ¶
type SnapshotManifestV1 struct {
Format string `json:"format"`
Version uint16 `json:"version"`
GroupID GroupID `json:"group_id"`
NodeID NodeID `json:"node_id"`
LastIncludedTerm uint64 `json:"last_included_term"`
LastIncludedIndex uint64 `json:"last_included_index"`
AppliedCommandLSN uint64 `json:"applied_command_lsn"`
LogicalDigestV1 string `json:"logical_digest_v1"`
Scope SnapshotScopeIdentityV1 `json:"scope"`
CreatedAt time.Time `json:"created_at"`
}
SnapshotManifestV1 is a metadata-only export contract. It describes the durable local FSM point and logical digest only; it does not copy snapshot files, install state into another DB, replay tails, truncate Raft logs, rejoin nodes, or claim that the exported metadata can serve reads.
func DecodeSnapshotManifestV1 ¶
func DecodeSnapshotManifestV1(src []byte, expectedScope SnapshotScopeIdentityV1) (SnapshotManifestV1, error)
func (SnapshotManifestV1) Validate ¶
func (m SnapshotManifestV1) Validate(expectedScope SnapshotScopeIdentityV1) error
type SnapshotScopeIdentityV1 ¶
type SnapshotScopeIdentityV1 struct {
ScopeRule string `json:"scope_rule"`
DatabaseScope string `json:"database_scope"`
CatalogScope string `json:"catalog_scope"`
}
SnapshotScopeIdentityV1 is the logical state scope covered by a snapshot manifest. It must match the receiver's expected scope before any later snapshot install/export integration may trust the metadata.
type StaticAdmissionProvider ¶
type StaticAdmissionProvider struct {
Status AdmissionStatus
Err error
}
StaticAdmissionProvider is a small deterministic AdmissionProvider useful for tests and single-node smoke wiring. Production providers should surface live leader/follower/unavailable state from the selected consensus adapter.
func (StaticAdmissionProvider) ClusterAdmissionStatus ¶
func (p StaticAdmissionProvider) ClusterAdmissionStatus(context.Context) (AdmissionStatus, error)
type StorageLayout ¶
type StorageLayout struct {
RootDir string
NodeDir string
GroupDir string
LogDir string
StableDir string
ApplyDir string
SnapshotDir string
PeerDirs []PeerStorageDir
}
StorageLayout is the deterministic local storage identity for one node in one Raft group.
type SubmitResultV1 ¶
type SubmitResultV1 struct {
ActualAck iwire.AckPolicy
CommittedRecoverable bool
DecodedEntry raftentry.CommandEntryV1
ApplyResult raftentry.ApplyResultV1
CommittedEntry CommittedCommandEntryV1
Evidence CommitEvidenceV1
CatalogVersion uint64
HasCatalogVersion bool
}