Documentation
¶
Overview ¶
Package snapshot provides streaming directory archival and restoration using tar and zstd.
Index ¶
- func Create(ctx context.Context, remote cache.Cache, key cache.Key, directory string, ...) error
- func CreatePaths(ctx context.Context, remote cache.Cache, key cache.Key, ...) (returnErr error)
- func Extract(ctx context.Context, r io.Reader, directory string, threads int) error
- func Restore(ctx context.Context, remote cache.Cache, key cache.Key, directory string, ...) (returnErr error)
- func StreamTo(ctx context.Context, w io.Writer, directory string, excludePatterns []string, ...) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Create ¶
func Create(ctx context.Context, remote cache.Cache, key cache.Key, directory string, ttl time.Duration, excludePatterns []string, threads int, extraHeaders ...http.Header) error
Create archives a directory using tar with zstd compression, then uploads to the cache.
The archive preserves all file permissions, ownership, and symlinks. The operation is fully streaming - no temporary files are created. Exclude patterns use tar's --exclude syntax. threads controls zstd parallelism; 0 uses all available CPU cores. Any extra headers are merged into the cache metadata alongside the default Content-Type and Content-Disposition headers.
func CreatePaths ¶
func CreatePaths(ctx context.Context, remote cache.Cache, key cache.Key, baseDir, archiveName string, includePaths []string, ttl time.Duration, excludePatterns []string, threads int, extraHeaders ...http.Header) (returnErr error)
CreatePaths archives named paths within baseDir using tar with zstd compression, then uploads the resulting archive to the cache.
The archive preserves all file permissions, ownership, and symlinks. Each entry in includePaths is archived relative to baseDir and must exist. Exclude patterns use tar's --exclude syntax. threads controls zstd parallelism; 0 uses all available CPU cores.
func Extract ¶
Extract decompresses a zstd+tar stream into directory, preserving all file permissions, ownership, and symlinks. threads controls zstd parallelism; 0 uses all available CPU cores.
func Restore ¶
func Restore(ctx context.Context, remote cache.Cache, key cache.Key, directory string, threads int) (returnErr error)
Restore downloads an archive from the cache and extracts it to a directory.
The archive is decompressed with zstd and extracted with tar, preserving all file permissions, ownership, and symlinks. The operation is fully streaming - no temporary files are created. threads controls zstd parallelism; 0 uses all available CPU cores.
func StreamTo ¶
func StreamTo(ctx context.Context, w io.Writer, directory string, excludePatterns []string, threads int) error
StreamTo archives a directory using tar with zstd compression and streams the output directly to w. Unlike Create, it does not upload to any cache backend. This is used on cache miss to serve the client immediately while a background job populates the cache.
Types ¶
This section is empty.