files

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxWorkers is the default number of workers to use for validation when a
	// caller does not specify one (numWorkers <= 0).
	MaxWorkers = 16
)

Variables

View Source
var ErrFileLocked = errors.New("file is locked for reading")

ErrFileLocked is returned when a file cannot be removed because it's locked for reading

Functions

func DecodeSyncEntry

func DecodeSyncEntry(data []byte) (*pb.SyncEntry, error)

DecodeSyncEntry deserializes a SyncEntry from bytes

func EncodeSyncEntry

func EncodeSyncEntry(entry *pb.SyncEntry) ([]byte, error)

EncodeSyncEntry serializes a SyncEntry to bytes

Types

type FileManager

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

FileManager manages all files in the files directory

func NewFileManager

func NewFileManager(basePath string, compactThreshold int64) (*FileManager, error)

NewFileManager creates a new FileManager for managing files. The compactThreshold parameter determines which files need to be fsynced immediately (files larger than this threshold are never compacted).

func (*FileManager) Read

func (fm *FileManager) Read(filePath string, length int64) (io.ReadCloser, error)

Read reads a value from a file for the given key

func (*FileManager) Remove

func (fm *FileManager) Remove(filePath string) error

Remove removes a file for the given key without blocking if it's being read

func (*FileManager) Write

func (fm *FileManager) Write(key string, reader io.Reader) (string, uint32, int64, error)

Write writes a value to a file for the given key Returns the file path, checksum, and number of bytes written.

type RecoveryManager

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

RecoveryManager handles startup recovery and validation of files in the compaction index

func NewRecoveryManager

func NewRecoveryManager(meta *metadata.MetaDB, filesPath string, numWorkers int) *RecoveryManager

NewRecoveryManager creates a new recovery manager. numWorkers sets the number of parallel validation workers; values <= 0 fall back to MaxWorkers.

func (*RecoveryManager) RecoverOnStartup

func (r *RecoveryManager) RecoverOnStartup() error

RecoverOnStartup validates all files in the compaction index and cleans up corrupted files

type RecoveryStats

type RecoveryStats struct {
	Total     int
	Valid     int
	Corrupted int
	Stale     int
	Orphaned  int
	Missing   int
	Duration  time.Duration
}

RecoveryStats tracks statistics during recovery

type ValidationResult

type ValidationResult struct {
	SyncKey     []byte           // The sync index key
	FilePath    string           // Path to the file
	MetadataKey string           // Metadata key if found
	Status      ValidationStatus // Validation status
	Error       error            // Any error encountered
}

ValidationResult contains the result of validating a sync entry

type ValidationStatus

type ValidationStatus int

ValidationStatus represents the status of a file during validation

const (
	StatusValid ValidationStatus = iota
	StatusCorrupted
	StatusStale
	StatusOrphaned
	StatusMissing
)

func (ValidationStatus) String

func (s ValidationStatus) String() string

Jump to

Keyboard shortcuts

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