Documentation
¶
Index ¶
- Constants
- Variables
- func DirectoryFileSize(root string) (int64, error)
- func ResolveTargetState(kind SnapshotKind, requested string) (string, error)
- func SaveTypedRecord[T any](store *Store, record *TypedRecord[T]) error
- type ListSnapshotsFilter
- type Record
- type Snapshot
- type SnapshotCompressionAlgorithm
- type SnapshotCompressionConfig
- type SnapshotKind
- type Store
- func (s *Store) Delete(snapshotID string) error
- func (s *Store) EnsureNameAvailable(sourceInstanceID, snapshotName string) error
- func (s *Store) Get(snapshotID string) (*Snapshot, error)
- func (s *Store) List(filter *ListSnapshotsFilter) ([]Snapshot, error)
- func (s *Store) ListRecords() ([]Record, error)
- func (s *Store) LoadRecord(snapshotID string) (*Record, error)
- func (s *Store) SaveRecord(record *Record) error
- type TypedRecord
Constants ¶
const ( StateStopped = "Stopped" StateStandby = "Standby" StateRunning = "Running" )
const ( DefaultSnapshotCompressionZstdLevel = 1 MinSnapshotCompressionZstdLevel = 1 MaxSnapshotCompressionZstdLevel = 19 DefaultSnapshotCompressionLz4Level = 0 MinSnapshotCompressionLz4Level = 0 MaxSnapshotCompressionLz4Level = 9 )
const ( SnapshotCompressionStateNone = "none" SnapshotCompressionStateCompressing = "compressing" SnapshotCompressionStateCompressed = "compressed" SnapshotCompressionStateError = "error" )
Variables ¶
var ( ErrNotFound = errors.New("snapshot not found") ErrNameExists = errors.New("snapshot name already exists") )
Functions ¶
func DirectoryFileSize ¶
func ResolveTargetState ¶
func ResolveTargetState(kind SnapshotKind, requested string) (string, error)
ResolveTargetState applies snapshot defaults and validates requested target states for restore/fork flows.
func SaveTypedRecord ¶
func SaveTypedRecord[T any](store *Store, record *TypedRecord[T]) error
Types ¶
type ListSnapshotsFilter ¶
type ListSnapshotsFilter struct {
SourceInstanceID *string
Kind *SnapshotKind
Name *string
Tags tags.Tags
}
ListSnapshotsFilter contains optional filters for listing snapshots.
func (*ListSnapshotsFilter) Matches ¶
func (f *ListSnapshotsFilter) Matches(snapshot *Snapshot) bool
Matches returns true if the given snapshot satisfies all filter criteria.
type Record ¶
type Record struct {
Snapshot Snapshot `json:"snapshot"`
StoredMetadata json.RawMessage `json:"stored_metadata"`
}
Record is the persisted representation of a snapshot plus source metadata.
type Snapshot ¶
type Snapshot struct {
Id string `json:"id"`
Name string `json:"name"`
Kind SnapshotKind `json:"kind"`
Tags tags.Tags `json:"tags,omitempty"`
SourceInstanceID string `json:"source_instance_id"`
SourceName string `json:"source_instance_name"`
SourceHypervisor hypervisor.Type
CreatedAt time.Time `json:"created_at"`
SizeBytes int64 `json:"size_bytes"`
CompressionState string `json:"compression_state,omitempty"`
CompressionError string `json:"compression_error,omitempty"`
Compression *SnapshotCompressionConfig `json:"compression,omitempty"`
CompressedSizeBytes *int64 `json:"compressed_size_bytes,omitempty"`
UncompressedSizeBytes *int64 `json:"uncompressed_size_bytes,omitempty"`
}
Snapshot is a centrally stored immutable snapshot resource.
type SnapshotCompressionAlgorithm ¶
type SnapshotCompressionAlgorithm string
SnapshotCompressionAlgorithm defines supported compression algorithms.
const ( SnapshotCompressionAlgorithmZstd SnapshotCompressionAlgorithm = "zstd" SnapshotCompressionAlgorithmLz4 SnapshotCompressionAlgorithm = "lz4" )
type SnapshotCompressionConfig ¶
type SnapshotCompressionConfig struct {
Enabled bool `json:"enabled"`
Algorithm SnapshotCompressionAlgorithm `json:"algorithm,omitempty"`
Level *int `json:"level,omitempty"`
}
SnapshotCompressionConfig defines requested or effective compression config.
type SnapshotKind ¶
type SnapshotKind string
SnapshotKind determines how snapshot data is captured and restored.
const ( // SnapshotKindStandby captures snapshot-based standby state (memory/device/disk). SnapshotKindStandby SnapshotKind = "Standby" // SnapshotKindStopped captures stopped-state disk+metadata only. SnapshotKindStopped SnapshotKind = "Stopped" )
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store handles snapshot metadata persistence under paths.SnapshotStoreDir().
func (*Store) EnsureNameAvailable ¶
func (*Store) ListRecords ¶
func (*Store) SaveRecord ¶
type TypedRecord ¶
TypedRecord is a strongly-typed snapshot record for callers that want structured stored metadata instead of json.RawMessage.
func ListTypedRecords ¶
func ListTypedRecords[T any](store *Store) ([]TypedRecord[T], error)
func LoadTypedRecord ¶
func LoadTypedRecord[T any](store *Store, snapshotID string) (*TypedRecord[T], error)