local

package
v0.3.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Opt added in v0.2.0

type Opt func(*options)

func WithDir added in v0.2.0

func WithDir(path string) Opt

WithDir adds directory to reading/writing files from/to.

func WithDirList added in v0.3.0

func WithDirList(pathList []string) Opt

WithDirList adds a directory list to read files from. Is used only for Reader.

func WithFile added in v0.2.0

func WithFile(path string) Opt

WithFile adds a file path to reading/writing from/to.

func WithFileList added in v0.3.0

func WithFileList(pathList []string) Opt

WithFileList adds a file list to read from. Is used only for Reader.

func WithNestedDir added in v0.2.0

func WithNestedDir() Opt

WithNestedDir adds withNestedDir = true parameter. That means that we won't skip nested folders.

func WithRemoveFiles added in v0.2.0

func WithRemoveFiles() Opt

WithRemoveFiles adds remove files flag, so all files will be removed from backup folder before backup. Is used only for Writer.

func WithSkipDirCheck added in v0.2.0

func WithSkipDirCheck() Opt

WithSkipDirCheck adds skip dir check flags. Which means that backup directory won't be checked for emptiness.

func WithValidator added in v0.2.0

func WithValidator(v validator) Opt

WithValidator adds validator to Reader, so files will be validated before reading. Is used only for Reader.

type Reader added in v0.2.0

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

Reader represents local storage reader.

func NewReader added in v0.2.0

func NewReader(opts ...Opt) (*Reader, error)

NewReader creates a new local directory/file Reader. Must be called with WithDir(path string) or WithFile(path string) - mandatory. Can be called with WithValidator(v validator) - optional.

func (*Reader) GetType added in v0.2.0

func (r *Reader) GetType() string

GetType returns the type of the reader.

func (*Reader) StreamFile added in v0.2.0

func (r *Reader) StreamFile(
	ctx context.Context, filename string, readersCh chan<- io.ReadCloser, errorsCh chan<- error)

StreamFile opens single file and sends io.Readers to the `readersCh` In case of an error, it is sent to the `errorsCh` channel.

func (*Reader) StreamFiles added in v0.2.0

func (r *Reader) StreamFiles(
	ctx context.Context, readersCh chan<- io.ReadCloser, errorsCh chan<- error,
)

StreamFiles reads file/directory from disk and sends io.Readers to the `readersCh` communication channel for lazy loading. In case of an error, it is sent to the `errorsCh` channel.

type Writer

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

Writer represents a local storage writer.

func NewWriter added in v0.2.0

func NewWriter(ctx context.Context, opts ...Opt) (*Writer, error)

NewWriter creates a new writer for local directory/file writes. Must be called with WithDir(path string) or WithFile(path string) - mandatory. Can be called with WithRemoveFiles() - optional.

func (*Writer) GetType

func (w *Writer) GetType() string

GetType return `localType` type of storage. Used in logging.

func (*Writer) NewWriter

func (w *Writer) NewWriter(ctx context.Context, fileName string) (io.WriteCloser, error)

NewWriter creates a new backup file in the given directory. The file name is based on the specified fileName.

func (*Writer) RemoveFiles added in v0.2.0

func (w *Writer) RemoveFiles(ctx context.Context) error

RemoveFiles removes a backup file or files from directory.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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