storage

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: May 8, 2020 License: GPL-3.0 Imports: 8 Imported by: 2 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 Batcher added in v0.5.0

type Batcher interface {
	PutMany() (batch chan<- record.Record, errs <-chan error)
}

Batcher defines the database storage API for backends that support batch operations.

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(ctx context.Context) error

Maintain runs a light maintenance operation on the database.

func (*InjectBase) MaintainRecordStates added in v0.5.2

func (i *InjectBase) MaintainRecordStates(ctx context.Context, purgeDeletedBefore time.Time) error

MaintainRecordStates maintains records states in the database.

func (*InjectBase) MaintainThorough

func (i *InjectBase) MaintainThorough(ctx context.Context) error

MaintainThorough runs a thorough maintenance operation on the database.

func (*InjectBase) Put

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

Put stores a record in the database.

func (*InjectBase) PutMany added in v0.5.0

func (i *InjectBase) PutMany() (batch chan record.Record, err chan error)

PutMany stores many records 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) (record.Record, error)
	Delete(key string) error
	Query(q *query.Query, local, internal bool) (*iterator.Iterator, error)

	ReadOnly() bool
	Injected() bool
	Maintain(ctx context.Context) error
	MaintainThorough(ctx context.Context) error
	MaintainRecordStates(ctx context.Context, purgeDeletedBefore time.Time) 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