backup

package
v8.24.2 Latest Latest
Warning

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

Go to latest
Published: May 4, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadConfigFile

func ReadConfigFile(filename string) ([]byte, error)

ReadConfigFile reads the config file and returns the data. It also expands any environment variables in the config file.

func ResetStats

func ResetStats()

ResetStats resets the expvar stats for this module. Mostly for test purposes.

Types

type Config

type Config struct {
	Version    int              `json:"version"`
	Type       auto.StorageType `json:"type"`
	NoCompress bool             `json:"no_compress,omitempty"`
	Timestamp  bool             `json:"timestamp"`
	Vacuum     bool             `json:"vacuum,omitempty"`
	Interval   auto.Duration    `json:"interval"`
	Sub        json.RawMessage  `json:"sub"`
}

Config is the config file format for the upload service

func Unmarshal

func Unmarshal(data []byte) (*Config, *aws.S3Config, error)

Unmarshal unmarshals the config file and returns the config and subconfig

type DataProvider

type DataProvider interface {
	// LastIndex returns the cluster-wide index the data managed by the DataProvider was
	// last modified by.
	LastIndex() (uint64, error)

	// Provide writes the data-for-upload to the writer.
	Provide(w io.Writer) error
}

DataProvider is an interface for providing data to be uploaded. The Uploader service will call Provide() to have the data-for-upload to be written to the to the file specified by path.

type StorageClient

type StorageClient interface {
	// Upload uploads the data from the given reader to the storage service.
	// id is a identifier for the data, and will be stored along with
	// the data in the storage service.
	Upload(ctx context.Context, reader io.Reader, id string) error

	// CurrentID returns the ID of the data in the Storage service.
	// It is always read from the Storage service, and a cached
	// value is never returned.
	CurrentID(ctx context.Context) (string, error)

	fmt.Stringer
}

StorageClient is an interface for uploading data to a storage service.

type Uploader

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

Uploader is a service that periodically uploads data to a storage service.

func NewUploader

func NewUploader(storageClient StorageClient, dataProvider DataProvider, interval time.Duration) *Uploader

NewUploader creates a new Uploader service.

func (*Uploader) Start

func (u *Uploader) Start(ctx context.Context, isUploadEnabled func() bool) chan struct{}

Start starts the Uploader service.

func (*Uploader) Stats

func (u *Uploader) Stats() (map[string]interface{}, error)

Stats returns the stats for the Uploader service.

Jump to

Keyboard shortcuts

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