binarystorage

package
v0.0.0-...-a753888 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: AGPL-3.0 Imports: 11 Imported by: 22

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Metadata

type Metadata struct {
	Version string
	Size    int64
	SHA256  string
}

Metadata describes a binary file stored in the storage.

type Storage

type Storage interface {
	// Add adds the binary file and metadata into state, replacing existing
	// metadata if any exists with the specified version.
	Add(io.Reader, Metadata) error

	// Open returns the Metadata and binary file contents for the specified
	// version if it exists, else an error satisfying errors.IsNotFound.
	Open(version string) (Metadata, io.ReadCloser, error)

	// AllMetadata returns metadata for the full list of binary files in the
	// catalogue.
	AllMetadata() ([]Metadata, error)

	// Metadata returns the Metadata for the specified version if it exists,
	// else an error satisfying errors.IsNotFound.
	Metadata(version string) (Metadata, error)
}

Storage provides methods for storing and retrieving binary files by version.

func New

func New(
	modelUUID string,
	managedStorage blobstore.ManagedStorage,
	metadataCollection mongo.Collection,
	runner jujutxn.Runner,
) Storage

New constructs a new Storage that stores binary files in the provided ManagedStorage, and metadata in the provided collection using the provided transaction runner.

func NewLayeredStorage

func NewLayeredStorage(s ...Storage) (Storage, error)

NewLayeredStorage wraps multiple Storages such all of their metadata can be listed and fetched. The later entries in the list have lower precedence than the earlier ones. The first entry in the list is always used for mutating operations.

type StorageCloser

type StorageCloser interface {
	Storage
	Close() error
}

StorageCloser extends the Storage interface with a Close method.

Jump to

Keyboard shortcuts

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