backup

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2022 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HTTPLoader

type HTTPLoader struct {
	URL    string
	Client *http.Client
}

HTTPLoader provides a source for restoring a backup from a URL. The contained http client is used for the request.

func (HTTPLoader) Load

func (h HTTPLoader) Load(ctx context.Context) (io.ReadCloser, error)

Load a backup set from the URL in the http loader. Returns the response body as a stream.

type ID

type ID string

ID of a backup

func (ID) Cancel

func (id ID) Cancel()

Status returns the status of the jobState with the id. Returns nil if the jobState cannot be found.

func (ID) Status

func (id ID) Status() *Status

Status returns the status of the jobState with the id. Returns nil if the jobState cannot be found.

func (ID) String

func (id ID) String() string

type Loader

type Loader interface {
	Load(ctx context.Context) (io.ReadCloser, error)
}

Loader provides a source for loading a backup set.

type Request

type Request struct {
	DB     *rankdb.Manager
	Cancel context.CancelFunc
	Dst    Saver
	Lists  rankdb.ListIDs
	ErrCh  <-chan error
}

Request is a request to start a backup on certain lists on a DB to a Saver.

func (Request) Start

func (req Request) Start(bg context.Context) ID

backupLists backups elements Only one list will be processing at the time.

type RestoreInfo

type RestoreInfo struct {
	// Source to read the data.
	Source Loader
	// Destinatio DB where lists should be stored.
	DB *rankdb.Manager
	// Replace existing lists.
	Replace bool
	// Cache assiciated with the DB.
	Cache rankdb.Cache

	// ListIDPrefix contains a prefix to apply to all lists.
	ListIDPrefix string
	// ListIDPrefix contains a suffix to apply to all lists.
	ListIDSuffix string
}

RestoreInfo contains restoration info.

func (*RestoreInfo) Restore

func (ri *RestoreInfo) Restore(ctx context.Context) (*RestoreResult, error)

Restore a backup set. 'ri' should contain all needed information.

type RestoreResult

type RestoreResult struct {
	Restored int
	Skipped  int
	Failed   map[string]string
}

RestoreResult is the result of a restore operation that completed.

type Saver

type Saver interface {
	Save(ctx context.Context) (io.WriteCloser, error)
}

Saver provides a destination for saving a backup.

type Status

type Status struct {
	// Custom information provided by backup
	Custom map[string]string
	// URI of backed up content. Used for restore.
	Done bool
	// Failed operations, indexed by list IDs
	Errors map[string]string
	// Number of lists to be backed up
	Lists int
	// Number of lists done.
	ListsDone int
	// Size of stored data
	Size int64
	// Storage used for backup
	Storage string
	// Successful operations, list IDs
	Success []string

	Cancelled bool
	Started   time.Time
	Finished  *time.Time
}

type WrapReader

type WrapReader struct {
	io.ReadCloser
}

WrapReader will wrap an io.Reader so it can be used for restoring a backup.

func (WrapReader) Load

func (h WrapReader) Load(ctx context.Context) (io.ReadCloser, error)

Load will return the wrapped ReadCloser.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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