Documentation
¶
Index ¶
- Constants
- Variables
- func ApplyExpiryPolicy(snapshots []SnapshotInfo, policy ExpiryPolicy) []string
- func ParseSnapshotName(name string) (time.Time, error)
- type BloomFilter
- 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
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
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 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