binarystorage

package
v0.0.0-...-2ee77c6 Latest Latest
Warning

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

Go to latest
Published: May 22, 2024 License: AGPL-3.0 Imports: 10 Imported by: 22

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ManagedStorage

type ManagedStorage interface {
	// Get returns a reader for data at path, namespaced to the bucket.
	// If the data is still being uploaded and is not fully written yet,
	// an ErrUploadPending error is returned. This means the path is valid but
	// the caller should try again to retrieve the data.
	Get(ctx context.Context, path string) (r io.ReadCloser, length int64, err error)

	// Put stores data from reader at path, namespaced to the bucket.
	Put(ctx context.Context, path string, r io.Reader, length int64) error

	// Remove deletes data at path, namespaced to the bucket.
	Remove(ctx context.Context, path string) error
}

ManagedStorage instances persist data for a bucket, for a user, or globally. (Only bucket storage is currently implemented).

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(context.Context, 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(ctx context.Context, 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(
	managedStorage 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.

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