store

package
v0.0.0-...-a17a3e0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2017 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Ver001        = Version("0.0.1")
	VerAlpha001_2 = Version("0.0.1-alpha-2")
	VerNone       = Version("")

	VerCurrent = Ver001
)

Variables

View Source
var (
	VersionBucket = []byte("version")
)

Functions

func CheckExists

func CheckExists(b Bucket, key []byte) func(*bolt.Tx) error

func CheckNotExist

func CheckNotExist(b Bucket, key []byte) func(*bolt.Tx) error

func Delete

func Delete(b Bucket, key []byte) func(*bolt.Tx) error

func Error

func Error(err error) func(*bolt.Tx) error

func Errorf

func Errorf(fmt string, vs ...interface{}) func(*bolt.Tx) error

func ForEach

func ForEach(b Bucket, f func(k, v []byte) error) func(tx *bolt.Tx) error

func Get

func Get(b Bucket, key []byte) func(*bolt.Tx) ([]byte, error)

func GetNestedBucket

func GetNestedBucket(b *bolt.Bucket, buckets ...Bucket) (*bolt.Bucket, error)

GetNestedBucket attempts to get the nested Bucket from the given Bucket, returning an error if it is missing.

func IsExists

func IsExists(err error) bool

func IsMissing

func IsMissing(err error) bool

func IsMissingBucket

func IsMissingBucket(err error) bool

func Itob

func Itob(v int) []byte

Itob returns an 8-byte big endian representation of v.

func MakeNestedBucket

func MakeNestedBucket(b *bolt.Bucket, buckets ...Bucket) (*bolt.Bucket, error)

MakeNestedBucket creates the given Buckets on the given Bucket if they do not exist, returning any error, or the innermost nested Bucket.

func Marshal

func Marshal(b Bucket, from interface{}, key []byte) func(*bolt.Tx) error

func Migrate

func Migrate(v Version) func(*bolt.Tx) error

func MigrateFrom

func MigrateFrom(tx *bolt.Tx, from, to Version) error

func Prep

func Prep(buckets ...Bucket) func(*bolt.Tx) error

func Put

func Put(b Bucket, key, val []byte) func(*bolt.Tx) error

func PutV

func PutV(v Version) func(*bolt.Tx) error

func SetupBuckets

func SetupBuckets(buckets ...Bucket) func(*bolt.Tx) error

func Unmarshal

func Unmarshal(b Bucket, to interface{}, key []byte) func(*bolt.Tx) error

func Wrap

func Wrap(apps ...func(*bolt.Tx) error) func(*bolt.Tx) error

Types

type Bucket

type Bucket []byte

Bucket is an identifier for a package constant to define the BoltDB bucket where a resource is stored.

TODO: nested Buckets?

type Deleter

type Deleter interface {
	Delete(*bolt.Tx) error
}

type Deleters

type Deleters []Deleter

func (Deleters) DeleteAll

func (ds Deleters) DeleteAll(tx *bolt.Tx) error

type ErrMissingBucket

type ErrMissingBucket []byte

func (ErrMissingBucket) Error

func (e ErrMissingBucket) Error() string

type ExistsError

type ExistsError KeyError

func (ExistsError) Error

func (e ExistsError) Error() string

type ID

type ID uuid.UUID

ID is a JSON-serializable UUID.

func (ID) HashWith

func (i ID) HashWith(some string) ID

HashWith returns a V5 UUID (defined as the SHA-1 of the given ID and the given input string) as an ID.

func (ID) MarshalJSON

func (i ID) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshalder on ID.

func (*ID) UnmarshalJSON

func (i *ID) UnmarshalJSON(from []byte) error

UnmarshalJSON implements json.Unmarshaler on ID.

type KeyError

type KeyError struct {
	Key, Bucket []byte
}

type LoadStoreDeleter

type LoadStoreDeleter interface {
	Loader
	Storer
	Deleter
}

type LoadStorer

type LoadStorer interface {
	Loader
	Storer
}

LoadStorer is composed of a Loader and a Storer.

type Loader

type Loader interface {
	Load(interface{}) func(*bolt.Tx) error
}

Loader is a reference to an entity in the DB which can be Loaded into the given argument. This would typically be implemented using an ID. Consider it equivalent to a reference type, where the "address" is a databased entity. The *bolt.Tx may be a Read or a Write transaction.

type Loaders

type Loaders []Loader

func (Loaders) LoadAll

func (ls Loaders) LoadAll(into ...interface{}) func(*bolt.Tx) error

LoadAll loads all the given objects.

type MissingError

type MissingError KeyError

func (MissingError) Error

func (m MissingError) Error() string

type Mutation

type Mutation func(*bolt.Tx) error

func (Mutation) OrMissing

func (m Mutation) OrMissing(tx *bolt.Tx) error

type Resource

type Resource string

Resource can be used for package constants, etc. to name a resource.

type ResourceBox

type ResourceBox struct {
	Name     Resource    `json:"name"`
	Contents interface{} `json:"contents"`
}

ResourceBox is a container for the bytes and type of some encoded Resource.

type Resourcer

type Resourcer interface {
	Resource() Resource
}

Resourcer is something which has a Resource.

type Storer

type Storer interface {
	Store(interface{}) func(*bolt.Tx) error
}

Storer is an entity which can store its representation using a bolt Write transaction. Typically this should be implemented by an ID. A reference type should be passed so that Store can set its ID.

type Storers

type Storers []Storer

func (Storers) StoreAll

func (ss Storers) StoreAll(what ...interface{}) func(*bolt.Tx) error

StoreAll stores all the given objects.

type Version

type Version string

type View

type View func(*bolt.Tx) error

func (View) OrMissing

func (v View) OrMissing(tx *bolt.Tx) error

OrMissing is a View method which ignores any Missing errors. All other error values are passed through.

Jump to

Keyboard shortcuts

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