common

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2025 License: Apache-2.0 Imports: 14 Imported by: 2

Documentation

Index

Constants

View Source
const DefaultPollWarmDuration = time.Minute

DefaultPollWarmDuration is the interval between requests to cloud providers, to get file status during files restore.

Variables

View Source
var (
	ErrEmptyStorage   = errors.New("empty storage")
	ErrArchivedObject = errors.New("archived object")
)

ErrEmptyStorage describes the empty storage error for the restore operation.

Functions

func CleanPath

func CleanPath(path string, isS3 bool) string

CleanPath sanitizes the input path string based on the storage type (S3 or non-S3). For S3 storage, it removes the root path "/" as S3 uses empty string for root. For all storage types, it ensures proper trailing slash format except for empty or root paths. Returns the cleaned path string.

func ErrToChan

func ErrToChan(ctx context.Context, ch chan<- error, err error)

ErrToChan checks context before sending an error to errors chan. If context is already canceled and the reader must be stopped, no need to send error to errors chan.

func IsDirectory

func IsDirectory(prefix, fileName string) bool

IsDirectory determines if a given file name represents a directory within the specified prefix. It considers three cases:

  1. File name ends with "/" (definite directory)
  2. File name is within a prefix and contains "/" after the prefix
  3. File name contains "/" (general case)

Returns true if the file name represents a directory, false otherwise.

func PreSort

func PreSort(ctx context.Context, r reader, path string) error

PreSort performs pre-processing of backup files by sorting them before reading. It retrieves a list of objects from the specified path, sorts them according to the backup file naming conventions, and configures the reader to stream the sorted list. Returns an error if listing objects fails or if the sorting operation fails.

Types

type RetryableReader

type RetryableReader struct {
	// contains filtered or unexported fields
}

RetryableReader is a wrapper around the s3 reader that implements the retryable interface.

func NewRetryableReader

func NewRetryableReader(
	ctx context.Context,
	rangeReader rangeReader,
	retryPolicy *models.RetryPolicy,
	logger *slog.Logger,
) (*RetryableReader, error)

NewRetryableReader returns a new retryable reader.

func (*RetryableReader) Close

func (r *RetryableReader) Close() error

Close closes the reader.

func (*RetryableReader) Read

func (r *RetryableReader) Read(p []byte) (int, error)

Read reads from the stream.

type SkippedFiles

type SkippedFiles struct {
	// contains filtered or unexported fields
}

SkippedFiles collects information about files that were not processed during an operation.

func NewSkippedFiles

func NewSkippedFiles(prefixes []string) *SkippedFiles

NewSkippedFiles returns new SkippedFiles instance, to track skipped files.

func (*SkippedFiles) GetSkipped

func (s *SkippedFiles) GetSkipped() []string

GetSkipped returns a list of file paths that were skipped during the `StreamFlies` with skipPrefix.

func (*SkippedFiles) Skip

func (s *SkippedFiles) Skip(path string) bool

Skip check if file must be skipped. If yes, it will be added to filePaths.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL