54 lines
2.7 KiB
Go
54 lines
2.7 KiB
Go
package agate
|
|
|
|
import (
|
|
"context"
|
|
"gitea.unprism.ru/KRBL/Agate/store"
|
|
"io"
|
|
)
|
|
|
|
// SnapshotManager is an interface that defines operations for managing and interacting with snapshots.
|
|
type SnapshotManager interface {
|
|
// CreateSnapshot creates a new snapshot from the specified source directory, associating it with a given name and parent ID.
|
|
// Returns the created Snapshot with its metadata or an error if the process fails.
|
|
CreateSnapshot(ctx context.Context, sourceDir string, name string, parentID string) (*store.Snapshot, error)
|
|
|
|
// GetSnapshotDetails retrieves detailed metadata for a specific snapshot identified by its unique snapshotID.
|
|
// Returns a Snapshot object containing metadata
|
|
GetSnapshotDetails(ctx context.Context, snapshotID string) (*store.Snapshot, error)
|
|
|
|
// ListSnapshots retrieves a list of all available snapshots, returning their basic information as SnapshotInfo.
|
|
ListSnapshots(ctx context.Context) ([]store.SnapshotInfo, error)
|
|
|
|
// DeleteSnapshot removes a snapshot identified by snapshotID. Returns an error if the snapshot does not exist or cannot be deleted.
|
|
DeleteSnapshot(ctx context.Context, snapshotID string) error
|
|
|
|
// OpenFile retrieves and opens a file from the specified snapshot, returning a readable stream and an error, if any.
|
|
OpenFile(ctx context.Context, snapshotID string, filePath string) (io.ReadCloser, error)
|
|
|
|
// ExtractSnapshot extracts the contents of a specified snapshot to a target directory at the given path.
|
|
// Returns an error if the snapshot ID is invalid or the extraction fails.
|
|
ExtractSnapshot(ctx context.Context, snapshotID string, path string) error
|
|
|
|
// UpdateSnapshotMetadata updates the metadata of an existing snapshot, allowing changes to its name.
|
|
UpdateSnapshotMetadata(ctx context.Context, snapshotID string, newName string) error
|
|
}
|
|
|
|
type SnapshotServer interface {
|
|
// Start initializes and begins the server's operation, handling incoming requests or processes within the provided context.
|
|
Start(ctx context.Context) error
|
|
|
|
// Stop gracefully shuts down the server, releasing any allocated resources and ensuring all operations are completed.
|
|
Stop(ctx context.Context) error
|
|
}
|
|
|
|
type SnapshotClient interface {
|
|
// ListSnapshots retrieves a list of snapshots containing basic metadata, such as ID, name, parent ID, and creation time.
|
|
ListSnapshots(ctx context.Context) ([]store.SnapshotInfo, error)
|
|
|
|
// FetchSnapshotDetails retrieves detailed metadata about a specific snapshot identified by snapshotID.
|
|
FetchSnapshotDetails(ctx context.Context, snapshotID string) (*store.Snapshot, error)
|
|
|
|
// DownloadSnapshot retrieves the snapshot content for the given snapshotID and returns it as an io.ReadCloser.
|
|
DownloadSnapshot(ctx context.Context, snapshotID string) (io.ReadCloser, error)
|
|
}
|