storage

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2024 License: Apache-2.0 Imports: 3 Imported by: 14

Documentation

Overview

Package storage implements a low-level interface for storing blobs in stable storage such as a database.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(name string, fn StorageConstructor) error

Register registers a new Storage under a name. It is typically used in init functions.

Types

type DialOpts

type DialOpts func(*Opts) error

DialOpts is a daisy-chaining mechanism for setting options to a backend during Dial.

func WithKeyValue

func WithKeyValue(key, value string) DialOpts

WithKeyValue sets a key-value pair as option. If called multiple times with the same key, the last one wins.

func WithOptions

func WithOptions(options string) DialOpts

WithOptions parses a string in the format "key1=value1,key2=value2,..." where keys and values are specific to each storage backend. Neither key nor value may contain the characters "," or "=". Use WithKeyValue repeatedly if these characters need to be used.

type Lister

type Lister interface {
	// List returns a list of references contained by the storage backend.
	// The token argument is for pagination: it specifies a starting point
	// for the list. To obtain a complete list of references, pass an empty
	// string for the first call, and the last nextToken value for for each
	// subsequent call. The pagination tokens are opaque values particular
	// to the storage implementation.
	List(token string) (refs []upspin.ListRefsItem, nextToken string, err error)
}

Lister provides a mechanism to report the set of items held in a StoreServer. Clients can use a type assertion to verify whether the StoreServer implements this interface.

type Opts

type Opts struct {
	Opts map[string]string // key-value pair
}

Opts holds configuration options for the storage backend. It is meant to be used by implementations of Storage.

type Storage

type Storage interface {
	// LinkBase returns the base URL from which any ref may be downloaded.
	// If the backend does not offer direct links it returns
	// upspin.ErrNotSupported.
	LinkBase() (base string, err error)

	// Download retrieves the bytes associated with a ref.
	Download(ref string) ([]byte, error)

	// Put stores the contents given as ref on the storage backend.
	Put(ref string, contents []byte) error

	// Delete permanently removes all storage space associated
	// with a ref.
	Delete(ref string) error
}

Storage is a low-level storage interface for services to store their data permanently. Storage implementations must be safe for concurrent use.

func Dial

func Dial(name string, opts ...DialOpts) (Storage, error)

Dial dials the named storage backend using the dial options opts.

type StorageConstructor

type StorageConstructor func(*Opts) (Storage, error)

StorageConstructor is a function that initializes and returns a Storage implementation with the given options.

Directories

Path Synopsis
Package disk provides a storage.Storage that stores data on local disk.
Package disk provides a storage.Storage that stores data on local disk.
internal/local
Package local converts blob references into local path names for on-disk storage.
Package local converts blob references into local path names for on-disk storage.
Package storagetest implements simple types and utility functions to help test implementations of storage.S.
Package storagetest implements simple types and utility functions to help test implementations of storage.S.

Jump to

Keyboard shortcuts

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