Documentation
¶
Index ¶
Constants ¶
const ( // MaxWorkers is the default number of workers to use for validation when a // caller does not specify one (numWorkers <= 0). MaxWorkers = 16 )
Variables ¶
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 ¶
DecodeSyncEntry deserializes a SyncEntry from 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
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