storage

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2019 License: GPL-3.0 Imports: 6 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound = errors.New("storage entry could not be found")
)

Errors for storages

Functions

func Register

func Register(name string, factory Factory) error

Register registers a new storage type.

Types

type Factory

type Factory func(name, location string) (Interface, error)

A Factory creates a new database of it's type.

type InjectBase

type InjectBase struct{}

InjectBase is a dummy base structure to reduce boilerplate code for injected storage interfaces.

func (*InjectBase) Delete

func (i *InjectBase) Delete(key string) error

Delete deletes a record from the database.

func (*InjectBase) Get

func (i *InjectBase) Get(key string) (record.Record, error)

Get returns a database record.

func (*InjectBase) Injected

func (i *InjectBase) Injected() bool

Injected returns whether the database is injected.

func (*InjectBase) Maintain

func (i *InjectBase) Maintain() error

Maintain runs a light maintenance operation on the database.

func (*InjectBase) MaintainThorough

func (i *InjectBase) MaintainThorough() error

MaintainThorough runs a thorough maintenance operation on the database.

func (*InjectBase) Put

func (i *InjectBase) Put(m record.Record) error

Put stores a record in the database.

func (*InjectBase) Query

func (i *InjectBase) Query(q *query.Query, local, internal bool) (*iterator.Iterator, error)

Query returns a an iterator for the supplied query.

func (*InjectBase) ReadOnly

func (i *InjectBase) ReadOnly() bool

ReadOnly returns whether the database is read only.

func (*InjectBase) Shutdown

func (i *InjectBase) Shutdown() error

Shutdown shuts down the database.

type Interface

type Interface interface {
	Get(key string) (record.Record, error)
	Put(m record.Record) error
	Delete(key string) error
	Query(q *query.Query, local, internal bool) (*iterator.Iterator, error)

	ReadOnly() bool
	Injected() bool
	Maintain() error
	MaintainThorough() error
	Shutdown() error
}

Interface defines the database storage API.

func CreateDatabase

func CreateDatabase(name, storageType, location string) (Interface, error)

CreateDatabase starts a new database with the given name and storageType at location.

func StartDatabase

func StartDatabase(name, storageType, location string) (Interface, error)

StartDatabase starts a new database with the given name and storageType at location.

Directories

Path Synopsis
Package fstree provides a dead simple file-based database storage backend.
Package fstree provides a dead simple file-based database storage backend.

Jump to

Keyboard shortcuts

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