refstore

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnknownReference = errors.New("unknown reference")

Functions

func AvailableAdapters

func AvailableAdapters() (list []string)

func RegisterAdapter

func RegisterAdapter(name string, adapter AdapterConstructor)

RegisterAdapter will remember the given adapter with under the given name. It will panic, if the name is already taken.

Types

type Adapter

type Adapter interface {
	// CopyFile copies a file with the given ID to the target path. It may
	// return ErrUnknownReference if the ID is unknown.
	CopyFile(log *zap.Logger, id Identifier, w io.Writer) error

	// Store saves the content in the adapter backend.
	Store(log *zap.Logger, r io.Reader) error

	// Exists checks whether the given reference identifier exists in this
	// storage adapter.
	Exists(id Identifier) bool
}

The Adapter inteface describes the protocol to interact with different storage backends.

func NewStore

func NewStore(dsn string) (Adapter, error)

NewStore creates a new reference store with the given DSN. The adapter name is extracted from the DSN, i.e. the disk adapter requires a DSN of the form "disk://".

type AdapterConstructor

type AdapterConstructor func(*url.URL) (Adapter, error)

type ErrInvalidIdentifier

type ErrInvalidIdentifier struct {
	// contains filtered or unexported fields
}

func (*ErrInvalidIdentifier) Error

func (err *ErrInvalidIdentifier) Error() string

func (*ErrInvalidIdentifier) Unwrap

func (err *ErrInvalidIdentifier) Unwrap() error

type ErrStoreAlreadyTaken

type ErrStoreAlreadyTaken string

func (ErrStoreAlreadyTaken) Error

func (err ErrStoreAlreadyTaken) Error() string

type Identifier

type Identifier []byte

File references are identified by their checksum.

func NewIdentifier

func NewIdentifier(contents []byte) Identifier

NewIdentifier calculates the reference ID from the given file contents.

func ParseIdentifier

func ParseIdentifier(b []byte) (Identifier, error)

ParseIdentifier takes an input in the form "sha256:...." and transforms it into an Identifier. Parsing errors are reported as ErrInvalidIdentifier.

func ReadIdentifier

func ReadIdentifier(r io.Reader) (Identifier, error)

func (Identifier) Raw

func (id Identifier) Raw() string

func (Identifier) String

func (id Identifier) String() string

Directories

Path Synopsis
Package dir implements an on-disk reference storage adapter.
Package dir implements an on-disk reference storage adapter.
Package nop implements a no-op reference store adapter.
Package nop implements a no-op reference store adapter.

Jump to

Keyboard shortcuts

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