storage

package
v0.0.0-...-9997ea8 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: BSD-2-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrKeyNotFound is returned when a requested object does not exist.
	ErrKeyNotFound = errors.New("storage: key not found")
	// ErrInvalidKey is returned when a key is not a canonical storage key.
	ErrInvalidKey = errors.New("storage: invalid key")
	// ErrStorageMissing is returned when the storage itself is not there. A
	// reader treats that as an error -- a mistyped path must not read as an
	// empty storage -- while a writer creating the first backup of a new
	// storage treats it as "nothing stored yet".
	ErrStorageMissing = errors.New("storage: does not exist")
)

Functions

func ArchiveBackupID

func ArchiveBackupID(key string) (string, string, bool)

ArchiveBackupID splits an archive key into the backup id and the replicaset UUID it was produced for. It is the inverse of ArchiveKey: a backup id may itself contain dashes, so the key is parsed from the right, where the UUID has a fixed shape. False means the key does not name an archive of this layout.

func ArchiveKey

func ArchiveKey(backupID, replicasetUUID string) string

ArchiveKey returns a relative key for a replicaset backup archive object.

func CleanKey

func CleanKey(key string) (string, error)

CleanKey returns a canonical storage object key.

func CleanPrefix

func CleanPrefix(prefix string) (string, error)

CleanPrefix returns a canonical storage list prefix.

func DataPrefix

func DataPrefix() string

DataPrefix returns the relative key prefix for backup archives.

func GetBytes

func GetBytes(ctx context.Context, s Storage, key string) ([]byte, error)

GetBytes reads a small object into memory.

func ManifestBackupID

func ManifestBackupID(key string) (string, bool)

ManifestBackupID returns the backup id a manifest key belongs to. It is the inverse of ManifestKey, used to name an object whose content could not be read; false means the key is not a manifest key.

func ManifestKey

func ManifestKey(backupID string) string

ManifestKey returns a relative key for a cluster manifest object.

func ManifestsPrefix

func ManifestsPrefix() string

ManifestsPrefix returns the relative key prefix for backup manifests.

func PrefixWithSlash

func PrefixWithSlash(prefix string) string

PrefixWithSlash ensures the prefix ends with a trailing slash, unless it is empty.

func PutBytes

func PutBytes(ctx context.Context, s Storage, key string, b []byte) error

PutBytes stores a small object from memory.

Types

type ObjectInfo

type ObjectInfo struct {
	Key          string
	Size         int64
	LastModified time.Time
}

ObjectInfo describes one stored object.

type Storage

type Storage interface {
	// List returns objects whose key starts with prefix, sorted by key.
	List(ctx context.Context, prefix string) ([]ObjectInfo, error)
	// Get opens the object for reading, returning ErrKeyNotFound if it is absent.
	Get(ctx context.Context, key string) (io.ReadCloser, error)
	// Put stores the bytes read from r under key. size must be the exact,
	// non-negative number of bytes r yields; implementations reject a negative
	// size or a byte-count mismatch. Streaming with an unknown length is not
	// supported.
	Put(ctx context.Context, key string, r io.Reader, size int64) error
	// Delete removes the object; a missing object is not an error.
	Delete(ctx context.Context, key string) error
}

Storage describes a backup object storage backend.

Keys are canonical slash-separated paths (see CleanKey). Implementations must behave uniformly: Get reports a missing object via ErrKeyNotFound, List reports it via an empty (non-nil) result, Delete is idempotent (a missing key is not an error), List results are sorted by key, and every method honors ctx cancellation.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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