Documentation
¶
Index ¶
- Constants
- Variables
- func ApplyExpiryPolicy(snapshots []SnapshotInfo, policy ExpiryPolicy) []string
- func ParseSnapshotName(name string) (time.Time, error)
- func TestRealWorldBenchmark(t *testing.T)
- type BloomFilter
- type DataStore
- func (d *DataStore) AppendSnapshotData(id string, data []byte) (string, error)
- func (d *DataStore) Close() error
- func (d *DataStore) DeleteDiffData(baseID, targetID string) error
- func (d *DataStore) DeleteSnapshotData(id string) error
- func (d *DataStore) ReadDiffData(ref string) ([]byte, error)
- func (d *DataStore) ReadSnapshotData(ref string) ([]byte, error)
- func (d *DataStore) StreamDiffData(ref string, writer io.Writer) error
- func (d *DataStore) StreamSnapshotData(ref string, writer io.Writer) error
- func (d *DataStore) WriteDiffData(baseID, targetID string, data []byte) (string, error)
- func (d *DataStore) WriteSnapshotData(id string, data []byte) (string, error)
- type ExpiryPolicy
- type SnapshotInfo
- type SnapshotStore
- func (s *SnapshotStore) ApplyDiff(baseName, diffName string) ([]byte, error)
- func (s *SnapshotStore) ApplyExpiryPolicy() (int, error)
- func (s *SnapshotStore) Close() error
- func (s *SnapshotStore) ComputeDiff(oldName, newName string) ([]byte, error)
- func (s *SnapshotStore) CreateBloomFilterFromSnapshot(name string) (*BloomFilter, error)
- func (s *SnapshotStore) CreateSnapshot(name string, data []byte) error
- func (s *SnapshotStore) DeleteSnapshot(name string) error
- func (s *SnapshotStore) GetExpiryPolicy() ExpiryPolicy
- func (s *SnapshotStore) ListSnapshots() ([]string, error)
- func (s *SnapshotStore) QuerySnapshot(name string, filter func(*flashfs.FileEntry) bool) ([]*flashfs.FileEntry, error)
- func (s *SnapshotStore) ReadSnapshot(name string) ([]byte, error)
- func (s *SnapshotStore) SetCacheSize(size int)
- func (s *SnapshotStore) SetExpiryPolicy(policy ExpiryPolicy)
- func (s *SnapshotStore) StoreDiff(oldName, newName string) error
- func (s *SnapshotStore) WriteSnapshot(name string, data []byte) error
- type Store
- func (s *Store) Close() error
- func (s *Store) ComputeDiff(oldID, newID string) ([]serializer.DiffEntry, error)
- func (s *Store) CreateSnapshot(id string, description string, rootPath string, entries []walker.SnapshotEntry) error
- func (s *Store) DeleteDiff(oldID, newID string) error
- func (s *Store) DeleteSnapshot(id string) error
- func (s *Store) FindFilesByHash(snapshotID, hash string) (map[string]metadata.FileMetadata, error)
- func (s *Store) FindFilesByModTime(snapshotID string, startTime, endTime time.Time) (map[string]metadata.FileMetadata, error)
- func (s *Store) FindFilesByPattern(snapshotID, pattern string) (map[string]metadata.FileMetadata, error)
- func (s *Store) FindFilesBySize(snapshotID string, minSize, maxSize int64) (map[string]metadata.FileMetadata, error)
- func (s *Store) GetDiff(oldID, newID string) ([]serializer.DiffEntry, error)
- func (s *Store) GetSnapshot(id string) ([]walker.SnapshotEntry, error)
- func (s *Store) ListSnapshots() ([]metadata.SnapshotMetadata, error)
- func (s *Store) StoreDiff(oldID, newID string) error
- type StoreOptions
Constants ¶
const ( // DefaultCompression is the default compression level DefaultCompression = 3 // DefaultCacheSize is the default number of snapshots to cache DefaultCacheSize = 10 // SnapshotFileExt is the file extension for snapshots SnapshotFileExt = ".snap" // DiffFileExt is the file extension for diff files DiffFileExt = ".diff" )
Variables ¶
var ( // ErrSnapshotNotFound is returned when a snapshot is not found ErrSnapshotNotFound = errors.New("snapshot not found") // ErrInvalidSnapshot is returned when a snapshot is invalid ErrInvalidSnapshot = errors.New("invalid snapshot") )
Functions ¶
func ApplyExpiryPolicy ¶
func ApplyExpiryPolicy(snapshots []SnapshotInfo, policy ExpiryPolicy) []string
ApplyExpiryPolicy applies the expiry policy to a list of snapshots and returns the names of snapshots that should be deleted
func ParseSnapshotName ¶
ParseSnapshotName extracts the timestamp from a snapshot name Snapshot names are expected to be in the format: name-YYYYMMDD-HHMMSS.snap
func TestRealWorldBenchmark ¶ added in v0.2.0
TestRealWorldBenchmark performs a real-world benchmark on a user's home directory This test is skipped in CI environments
Types ¶
type BloomFilter ¶
type BloomFilter struct {
// contains filtered or unexported fields
}
BloomFilter implements a simple bloom filter for quick file existence checks
func NewBloomFilter ¶
func NewBloomFilter(size uint, numHash uint) *BloomFilter
NewBloomFilter creates a new bloom filter
func (*BloomFilter) Add ¶
func (b *BloomFilter) Add(data []byte)
Add adds an item to the bloom filter
func (*BloomFilter) Contains ¶
func (b *BloomFilter) Contains(data []byte) bool
Contains checks if an item might be in the bloom filter
type DataStore ¶ added in v0.2.0
type DataStore struct {
// contains filtered or unexported fields
}
DataStore handles the storage of actual snapshot and diff data using FlatBuffers
func NewDataStore ¶ added in v0.2.0
NewDataStore creates a new data store
func (*DataStore) AppendSnapshotData ¶ added in v0.2.0
AppendSnapshotData appends data to an existing snapshot data file
func (*DataStore) DeleteDiffData ¶ added in v0.2.0
DeleteDiffData deletes diff data from the data store
func (*DataStore) DeleteSnapshotData ¶ added in v0.2.0
DeleteSnapshotData deletes snapshot data from the data store
func (*DataStore) ReadDiffData ¶ added in v0.2.0
ReadDiffData reads diff data from the data store
func (*DataStore) ReadSnapshotData ¶ added in v0.2.0
ReadSnapshotData reads snapshot data from the data store
func (*DataStore) StreamDiffData ¶ added in v0.2.0
StreamDiffData streams diff data from the data store
func (*DataStore) StreamSnapshotData ¶ added in v0.2.0
StreamSnapshotData streams snapshot data from the data store
func (*DataStore) WriteDiffData ¶ added in v0.2.0
WriteDiffData writes diff data to the data store
type ExpiryPolicy ¶
type ExpiryPolicy struct {
// MaxSnapshots is the maximum number of snapshots to keep (0 = unlimited)
MaxSnapshots int
// MaxAge is the maximum age of snapshots to keep (0 = unlimited)
MaxAge time.Duration
// KeepHourly defines how many hourly snapshots to keep (0 = none)
KeepHourly int
// KeepDaily defines how many daily snapshots to keep (0 = none)
KeepDaily int
// KeepWeekly defines how many weekly snapshots to keep (0 = none)
KeepWeekly int
// KeepMonthly defines how many monthly snapshots to keep (0 = none)
KeepMonthly int
// KeepYearly defines how many yearly snapshots to keep (0 = none)
KeepYearly int
}
ExpiryPolicy defines how snapshots should be expired and rotated
func DefaultExpiryPolicy ¶
func DefaultExpiryPolicy() ExpiryPolicy
DefaultExpiryPolicy returns a default expiry policy
type SnapshotInfo ¶
SnapshotInfo contains metadata about a snapshot
type SnapshotStore ¶
type SnapshotStore struct {
// contains filtered or unexported fields
}
SnapshotStore manages snapshot storage operations
func NewSnapshotStore ¶
func NewSnapshotStore(baseDir string) (*SnapshotStore, error)
NewSnapshotStore creates a new snapshot store
func (*SnapshotStore) ApplyDiff ¶
func (s *SnapshotStore) ApplyDiff(baseName, diffName string) ([]byte, error)
ApplyDiff applies a diff to a snapshot
func (*SnapshotStore) ApplyExpiryPolicy ¶
func (s *SnapshotStore) ApplyExpiryPolicy() (int, error)
ApplyExpiryPolicy applies the current expiry policy to all snapshots
func (*SnapshotStore) ComputeDiff ¶
func (s *SnapshotStore) ComputeDiff(oldName, newName string) ([]byte, error)
ComputeDiff computes the difference between two snapshots
func (*SnapshotStore) CreateBloomFilterFromSnapshot ¶
func (s *SnapshotStore) CreateBloomFilterFromSnapshot(name string) (*BloomFilter, error)
CreateBloomFilterFromSnapshot creates a bloom filter from a snapshot
func (*SnapshotStore) CreateSnapshot ¶
func (s *SnapshotStore) CreateSnapshot(name string, data []byte) error
CreateSnapshot creates a new snapshot with the given data and applies the expiry policy
func (*SnapshotStore) DeleteSnapshot ¶
func (s *SnapshotStore) DeleteSnapshot(name string) error
DeleteSnapshot deletes a snapshot
func (*SnapshotStore) GetExpiryPolicy ¶
func (s *SnapshotStore) GetExpiryPolicy() ExpiryPolicy
GetExpiryPolicy returns the current expiry policy
func (*SnapshotStore) ListSnapshots ¶
func (s *SnapshotStore) ListSnapshots() ([]string, error)
ListSnapshots returns a list of available snapshots
func (*SnapshotStore) QuerySnapshot ¶
func (s *SnapshotStore) QuerySnapshot(name string, filter func(*flashfs.FileEntry) bool) ([]*flashfs.FileEntry, error)
QuerySnapshot queries a snapshot for entries matching criteria
func (*SnapshotStore) ReadSnapshot ¶
func (s *SnapshotStore) ReadSnapshot(name string) ([]byte, error)
ReadSnapshot reads a snapshot from disk or cache
func (*SnapshotStore) SetCacheSize ¶
func (s *SnapshotStore) SetCacheSize(size int)
SetCacheSize sets the maximum number of snapshots to cache
func (*SnapshotStore) SetExpiryPolicy ¶
func (s *SnapshotStore) SetExpiryPolicy(policy ExpiryPolicy)
SetExpiryPolicy sets the expiry policy for the snapshot store
func (*SnapshotStore) StoreDiff ¶
func (s *SnapshotStore) StoreDiff(oldName, newName string) error
StoreDiff stores a diff between two snapshots
func (*SnapshotStore) WriteSnapshot ¶
func (s *SnapshotStore) WriteSnapshot(name string, data []byte) error
WriteSnapshot writes a snapshot to disk with compression
type Store ¶ added in v0.2.0
type Store struct {
// contains filtered or unexported fields
}
Store represents a storage system that combines metadata and data storage
func NewStore ¶ added in v0.2.0
func NewStore(baseDir string, options StoreOptions) (*Store, error)
NewStore creates a new store
func (*Store) ComputeDiff ¶ added in v0.2.0
func (s *Store) ComputeDiff(oldID, newID string) ([]serializer.DiffEntry, error)
ComputeDiff computes the difference between two snapshots
func (*Store) CreateSnapshot ¶ added in v0.2.0
func (s *Store) CreateSnapshot(id string, description string, rootPath string, entries []walker.SnapshotEntry) error
CreateSnapshot creates a new snapshot
func (*Store) DeleteDiff ¶ added in v0.2.0
DeleteDiff deletes a diff between two snapshots
func (*Store) DeleteSnapshot ¶ added in v0.2.0
DeleteSnapshot deletes a snapshot
func (*Store) FindFilesByHash ¶ added in v0.2.0
FindFilesByHash finds files in a snapshot with a specific hash
func (*Store) FindFilesByModTime ¶ added in v0.2.0
func (s *Store) FindFilesByModTime(snapshotID string, startTime, endTime time.Time) (map[string]metadata.FileMetadata, error)
FindFilesByModTime finds files in a snapshot modified within a time range
func (*Store) FindFilesByPattern ¶ added in v0.2.0
func (s *Store) FindFilesByPattern(snapshotID, pattern string) (map[string]metadata.FileMetadata, error)
FindFilesByPattern finds files in a snapshot matching a pattern
func (*Store) FindFilesBySize ¶ added in v0.2.0
func (s *Store) FindFilesBySize(snapshotID string, minSize, maxSize int64) (map[string]metadata.FileMetadata, error)
FindFilesBySize finds files in a snapshot within a size range
func (*Store) GetDiff ¶ added in v0.2.0
func (s *Store) GetDiff(oldID, newID string) ([]serializer.DiffEntry, error)
GetDiff retrieves a diff between two snapshots
func (*Store) GetSnapshot ¶ added in v0.2.0
func (s *Store) GetSnapshot(id string) ([]walker.SnapshotEntry, error)
GetSnapshot retrieves a snapshot
func (*Store) ListSnapshots ¶ added in v0.2.0
func (s *Store) ListSnapshots() ([]metadata.SnapshotMetadata, error)
ListSnapshots lists all snapshots
type StoreOptions ¶ added in v0.2.0
StoreOptions represents options for configuring the store
func DefaultStoreOptions ¶ added in v0.2.0
func DefaultStoreOptions() StoreOptions
DefaultStoreOptions returns the default options for the store