db

package
v0.0.0-...-3e87057 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2018 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TypeBadger is identifier to specify that we want to use Badger
	// as metadata db
	TypeBadger = "badger"

	// TypeETCD is identifier to specify that we want to use ETCD
	// as metadata db
	TypeETCD = "etcd"
)

Variables

View Source
var (
	// ErrNotFound is the error returned by a metastor KV database,
	// in case metadata requested couldn't be found.
	ErrNotFound = errors.New("metastor: key couldn't be found")

	// ErrTimeout is the error returned by a metastor KV database,
	// in case the database timed out.
	ErrTimeout = errors.New("metastor: database timed out")

	// ErrUnavailable is the error returned by a metastor KV database,
	// in case the database is unavailable.
	ErrUnavailable = errors.New("metastor: database is unavailable")
)

Functions

This section is empty.

Types

type DB

type DB interface {
	// Set given key in the database equal to the processed metadata.
	Set(namespace, key, metadata []byte) error
	// Get the stored metadata from the database using the given key.
	Get(namespace, key []byte) (metadata []byte, err error)
	// Delete the metadata which is stored as the given key.
	Delete(namespace, key []byte) error
	// Update metadata stored as the given key,
	// as an in-memory-transaction, providing protection against data races.
	// When wishing to update metadata always use this method,
	// rather than a combination of Set+Get.
	Update(namespace, key []byte, cb UpdateCallback) error

	// ListKeys all keys in the given namespace.
	// The keys are sorted in lexicographically order.
	ListKeys(namespace []byte, cb ListCallback) error

	// Close any open (database) resources.
	Close() error
}

DB interface is the interface defining how to interact with a key value store, as ued for metadata storage. ALl DB implements are assumed to be threadsafe.

type InternalError

type InternalError struct {
	Type string
	Err  error
}

InternalError can be returned by a database as a generic internal error, retaining the actual internal error as part of the returned error.

func (*InternalError) Error

func (ie *InternalError) Error() string

Error implements error.Error

type ListCallback

type ListCallback func(key []byte) error

ListCallback is the type of callback used to process the listed keys

type UpdateCallback

type UpdateCallback func(orgMetadata []byte) (newMetadata []byte, err error)

UpdateCallback is the type of callback used to update the processed (encoded) metadata, which was already stored, previously.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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