storage

package
v1.6.27 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

Errors for storages.

View Source
var ErrNotImplemented = errors.New("not implemented")

ErrNotImplemented is returned when a function is not implemented by a storage.

Functions

func Register

func Register(name string, factory Factory) error

Register registers a new storage type.

Types

type Batcher

type Batcher interface {
	PutMany(shadowDelete bool) (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) MaintainRecordStates

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

MaintainRecordStates maintains records states in the database.

func (*InjectBase) Put

func (i *InjectBase) Put(m record.Record) (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 {
	// Primary 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)

	// Information and Control
	ReadOnly() bool
	Injected() bool
	Shutdown() error

	// Mandatory Record Maintenance
	MaintainRecordStates(ctx context.Context, purgeDeletedBefore time.Time, shadowDelete bool) 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.

type Maintainer

type Maintainer interface {
	Maintain(ctx context.Context) error
	MaintainThorough(ctx context.Context) error
}

Maintainer defines the database storage API for backends that require regular maintenance.

type MetaHandler

type MetaHandler interface {
	GetMeta(key string) (*record.Meta, error)
}

MetaHandler defines the database storage API for backends that support optimized fetching of only the metadata.

type Purger

type Purger interface {
	Purge(ctx context.Context, q *query.Query, local, internal, shadowDelete bool) (int, error)
}

Purger defines the database storage API for backends that support the purge operation.

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