Documentation
¶
Overview ¶
Package snapshot provides a service for capturing and comparing point-in-time snapshots of the working directory file system.
Index ¶
Constants ¶
const ( SnapshotTypeStart = "start" // Created at session start SnapshotTypeEnd = "end" // Created at session end SnapshotTypeManual = "manual" // User-triggered )
Snapshot type constants.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter implements session.SnapshotCreator using a snapshot Service. It bridges the session package (which uses the SnapshotCreator interface to avoid an import cycle) with the concrete snapshot.Service.
func NewAdapter ¶
NewAdapter wraps a Service in an Adapter that satisfies session.SnapshotCreator.
type DiffEntry ¶
type DiffEntry struct {
Path string `json:"path"`
Type DiffType `json:"type"`
OldHash string `json:"old_hash,omitempty"`
NewHash string `json:"new_hash,omitempty"`
OldSize int64 `json:"old_size,omitempty"`
NewSize int64 `json:"new_size,omitempty"`
}
DiffEntry represents a single file-level change between two snapshots.
type Manifest ¶
type Manifest struct {
Snapshot Snapshot `json:"snapshot"`
Files []SnapshotFile `json:"files"`
}
Manifest combines a Snapshot header with its full file list.
type Service ¶
type Service interface {
pubsub.Suscriber[Snapshot]
Create(ctx context.Context, sessionID, snapshotType, description string) (Snapshot, error)
Get(ctx context.Context, id string) (Snapshot, error)
GetManifest(ctx context.Context, id string) (Manifest, error)
List(ctx context.Context) ([]Snapshot, error)
ListBySession(ctx context.Context, sessionID string) ([]Snapshot, error)
Delete(ctx context.Context, id string) error
GetFileContent(ctx context.Context, snapshotID, fileHash string) ([]byte, error)
Compare(ctx context.Context, snapshotID1, snapshotID2 string) ([]DiffEntry, error)
Cleanup(ctx context.Context, maxAge int, maxCount int) error
Revert(ctx context.Context, snapshotID string) error
Apply(ctx context.Context, fromSnapshotID, toSnapshotID string) error
}
Service defines the public interface for the snapshot service.
func NewService ¶
NewService creates and returns a new snapshot Service. It reads the data directory from the application config and initialises both the file-based storage and the file-system scanner.
type Snapshot ¶
type Snapshot struct {
ID string `json:"id"`
SessionID string `json:"session_id"`
Type string `json:"type"` // start, end, manual
Description string `json:"description"`
WorkingDir string `json:"working_dir"`
FileCount int `json:"file_count"`
TotalSize int64 `json:"total_size"`
CreatedAt int64 `json:"created_at"`
}
Snapshot represents a point-in-time capture of the working directory.