libdb

package
v0.0.0-...-eb887e7 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Closable

type Closable interface {
	// Close the database
	Close()
}

A Closable is a handle or database that can be closed

type Database

type Database interface {
	ReadOnlyView
	WriterView

	// Return a subset of the database for usage
	Bucket(id []byte) Database

	// NextSequence returns the next natural sequence for insert-order-centric applications
	// Note this will cause implementations to lock while finding the natural sequence
	NextSequence() []byte

	// Convert view of current database or bucket into a read-only one.
	// This should not be considered a transaction, just special sauce.
	View(f ReadOnlyFunc) error

	// Obtain a read-write view of the database in a transaction
	Update(f WriterFunc) error

	// Close the database (might no-op)
	Close()
}

Database is the compound interface to the underlying database implementation

func Open

func Open(path string) (Database, error)

Open will return an opaque representation of the underlying database implementation suitable for usage within ferryd

type DbForeachFunc

type DbForeachFunc func(key, val []byte) error

DbForeachFunc is used in the root (untyped buckets)

type GobDecoderLight

type GobDecoderLight struct {
	// contains filtered or unexported fields
}

GobDecoderLight is a helper for decoding gob

func NewGobDecoderLight

func NewGobDecoderLight() *GobDecoderLight

NewGobDecoderLight returns a new lock-free decoder

func (*GobDecoderLight) DecodeType

func (g *GobDecoderLight) DecodeType(buf []byte, outT interface{}) error

DecodeType will attempt to decode the buffer into the pointer outT

type GobEncoderLight

type GobEncoderLight struct {
	// contains filtered or unexported fields
}

GobEncoderLight is a helper for encoding gob

func NewGobEncoderLight

func NewGobEncoderLight() *GobEncoderLight

NewGobEncoderLight returns a new lock-free encoder

func (*GobEncoderLight) EncodeType

func (g *GobEncoderLight) EncodeType(t interface{}) ([]byte, error)

EncodeType will convert give given pointer into a gob encoded byte set, and return them

type ReadOnlyFunc

type ReadOnlyFunc func(view ReadOnlyView) error

A ReadOnlyFunc is expected by the Database.View method

type ReadOnlyView

type ReadOnlyView interface {
	// Get an object from storage
	GetObject(id []byte, o interface{}) error

	// Determine if an object with that ID exists already
	HasObject(id []byte) (bool, error)

	// Attempt to decode the input into the given output pointer
	Decode(input []byte, o interface{}) error

	// For every key value pair, run the given function
	ForEach(f DbForeachFunc) error
}

ReadOnlyView offers a read-only API for the database. Note it cannot gain access to buckets again, so you should obtain the view from the bucket.

type WriterFunc

type WriterFunc func(db Database) error

A WriterFunc is used for batch write (transactional) views

type WriterView

type WriterView interface {

	// Delete an object from storage
	DeleteObject(id []byte) error

	// Put an object into storage (unique key)
	PutObject(id []byte, o interface{}) error
}

WriterView allows destructive write actions within the database

Jump to

Keyboard shortcuts

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