storage

package
v1.8.1-0...-0157f87 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: Apache-2.0 Imports: 7 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotExist is an error for file doesn't exists on storage
	ErrNotExist      = errors.New("no such file")
	ErrEmpty         = errors.New("file is empty")
	ErrUninitialized = errors.New("uninitialized")
)
View Source
var ErrCancelled = errors.New("backup canceled")

ErrCancelled means backup was canceled

Functions

func HasReadAccess

func HasReadAccess(ctx context.Context, stg Storage) error

HasReadAccess checks if the provided storage allows the reading of file content.

It gets the size (stat) and reads the content of the PBM init file.

ErrUninitialized is returned if there is no init file.

func IsInitialized

func IsInitialized(ctx context.Context, stg Storage) (bool, error)

IsInitialized checks if there is PBM init file on the storage.

func PrettySize

func PrettySize(size int64) string

func Upload

func Upload(
	ctx context.Context,
	src Source,
	dst Storage,
	compression compress.CompressionType,
	compressLevel *int,
	fname string,
	sizeb int64,
) (int64, error)

Upload writes data to dst from given src and returns an amount of written bytes

Types

type Canceller

type Canceller interface {
	Cancel()
}

type FileInfo added in v1.4.0

type FileInfo struct {
	Name string // with path
	Size int64
}

type Source

type Source interface {
	io.WriterTo
}

type Storage

type Storage interface {
	Type() Type
	Save(name string, data io.Reader, size int64) error
	SourceReader(name string) (io.ReadCloser, error)
	// FileStat returns file info. It returns error if file is empty or not exists.
	FileStat(name string) (FileInfo, error)
	// List scans path with prefix and returns all files with given suffix.
	// Both prefix and suffix can be omitted.
	List(prefix, suffix string) ([]FileInfo, error)
	// Delete deletes given file.
	// It returns storage.ErrNotExist if a file doesn't exists.
	Delete(name string) error
	// Copy makes a copy of the src objec/file under dst name
	Copy(src, dst string) error
}

type Type

type Type string

Type represents a type of the destination storage for backups

const (
	Undefined  Type = ""
	S3         Type = "s3"
	Azure      Type = "azure"
	Filesystem Type = "filesystem"
	Blackhole  Type = "blackhole"
)

func ParseType

func ParseType(s string) Type

ParseType parses string and returns storage type

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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