Index | Files | Directories

package storage

import ""

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


Package Files


func Register Uses

func Register(name string, fn StorageConstructor) error

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

type DialOpts Uses

type DialOpts func(*Opts) error

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

func WithKeyValue Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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

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

type StorageConstructor Uses

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

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


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

Package storage imports 3 packages (graph) and is imported by 10 packages. Updated 2020-01-29. Refresh now. Tools for package owners.