Agate/interfaces/snapshot.go
Alexander Lazarenko 13744f0500
Introduce gRPC-based snapshot client and server functionality.
Implemented gRPC client and server for snapshot management, enabling remote operations like listing, fetching, and downloading snapshots. Updated interfaces to support the new gRPC implementation and integrated server start functionality into the API.
2025-05-07 22:03:03 +03:00

48 lines
1.7 KiB
Go

package interfaces
import (
"context"
"io"
"unprism.ru/KRBL/agate/store"
)
// SnapshotManager defines the interface that the server needs to interact with snapshots
type SnapshotManager interface {
// GetSnapshotDetails retrieves detailed metadata for a specific snapshot
GetSnapshotDetails(ctx context.Context, snapshotID string) (*store.Snapshot, error)
// ListSnapshots retrieves a list of all available snapshots
ListSnapshots(ctx context.Context) ([]store.SnapshotInfo, error)
// OpenFile retrieves and opens a file from the specified snapshot
OpenFile(ctx context.Context, snapshotID string, filePath string) (io.ReadCloser, error)
// CreateSnapshot creates a new snapshot from the specified source directory
CreateSnapshot(ctx context.Context, sourceDir string, name string, parentID string) (*store.Snapshot, error)
}
// SnapshotServer defines the interface for a server that can share snapshots
type SnapshotServer interface {
// Start initializes and begins the server's operation
Start(ctx context.Context) error
// Stop gracefully shuts down the server
Stop(ctx context.Context) error
}
// SnapshotClient defines the interface for a client that can connect to a server and download snapshots
type SnapshotClient interface {
// ListSnapshots retrieves a list of snapshots from the server
ListSnapshots(ctx context.Context) ([]store.SnapshotInfo, error)
// FetchSnapshotDetails retrieves detailed information about a specific snapshot
FetchSnapshotDetails(ctx context.Context, snapshotID string) (*store.Snapshot, error)
// DownloadSnapshot downloads a snapshot from the server
DownloadSnapshot(ctx context.Context, snapshotID string, targetDir string, localParentID string) error
// Close closes the connection to the server
Close() error
}