honu

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2023 License: BSD-3-Clause Imports: 13 Imported by: 3

README

Honu

Go Reference Go Report Card GitHub Actions CI codecov

A library for embedded database replication

Benchmarks

Baseline comparison of honu database vs. pure leveldb performance to determine the overhead that honu adds:

BenchmarkHonuGet-8         	  466665	      2405 ns/op
BenchmarkLevelDBGet-8      	 1243785	       955.3 ns/op
BenchmarkHonuPut-8         	   21448	     55125 ns/op
BenchmarkLevelDBPut-8      	   24276	     52422 ns/op
BenchmarkHonuDelete-8      	   42298	     25136 ns/op
BenchmarkLevelDBDelete-8   	   76857	     16101 ns/op
BenchmarkHonuIter-8        	   63772	     18349 ns/op
BenchmarkLevelDBIter-8     	  255319	      4271 ns/op
BenchmarkHonuObject-8      	  480555	      2362 ns/op

Baseline Benchmarks

Documentation

Overview

Package honu provides a thin wrapper over an embedded database (leveldb, sqlite) that provides version history to object changes and anti-entropy replication.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

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

DB is a Honu embedded database. Currently DB simply wraps a leveldb database

func Open

func Open(uri string, options ...config.Option) (db *DB, err error)

Open a replicated embedded database with the specified URI. Database URIs should specify protocol:///relative/path/to/db for embedded databases. For absolute paths, specify protocol:////absolute/path/to/db.

func (*DB) Close

func (db *DB) Close() error

Close the database, allowing no further interactions.

func (*DB) Delete

func (db *DB) Delete(key []byte, options ...opts.Option) (_ *pb.Object, err error)

Delete the object represented by the key, creating a tombstone object.

func (*DB) Engine added in v0.2.8

func (db *DB) Engine() engine.Engine

Returns the underlying DB engine for direct access.

func (*DB) Get

func (db *DB) Get(key []byte, options ...opts.Option) (value []byte, err error)

Get the latest version of the object stored by the key.

func (*DB) Iter

func (db *DB) Iter(prefix []byte, options ...opts.Option) (i iterator.Iterator, err error)

Iter over a subset of keys specified by the prefix. TODO: provide better mechanisms for iteration.

func (*DB) Object

func (db *DB) Object(key []byte, options ...opts.Option) (_ *pb.Object, err error)

Object returns metadata associated with the latest object stored by the key. Object is the Get function to use if you want to fetch tombstones, otherwise use Get which will return a not found error.

func (*DB) Put

func (db *DB) Put(key, value []byte, options ...opts.Option) (_ *pb.Object, err error)

Put a new value to the specified key and update the version.

func (*DB) Update added in v0.2.6

func (db *DB) Update(obj *pb.Object, options ...opts.Option) (update UpdateType, err error)

Update an object directly in the database without modifying its version information. Update is to Put as Object is to Get - use Update when manually modifying the data store, for example during replication, but not for normal DB operations. Update also returns the type of update that ocurred, relative to the previous version.

type DSN

type DSN struct {
	Scheme string
	Path   string
}

DSN represents the parsed components of an embedded database service.

func ParseDSN

func ParseDSN(uri string) (_ *DSN, err error)

ParseDSN converts a database URI or URL string into a structured DSN representation.

type UpdateType added in v0.2.7

type UpdateType uint8

UpdateType is an intermediate solution to tracking what's happening to the version history when direct modifications are applied to the database. NOTE: this data type is subject to change in later versions and should be treated as a prototype only in production code.

const (
	UpdateNoChange UpdateType = iota // No change occurred (nothing was written to disk)
	UpdateForced                     // The update was forced, so the previous version was not checked
	UpdateLinear                     // The previous version is the parent of the updating version
	UpdateStomp                      // The previous version is concurrent but has a lower precedence than the updating version
	UpdateSkip                       // The previous version is later but is not concurrent nor linear from the updating version

)

func (UpdateType) String added in v0.2.7

func (u UpdateType) String() string

type VersionManager

type VersionManager struct {
	PID    uint64
	Owner  string
	Region string
}

VersionManager is configured with information associated with the local Replica in order to correctly implement Lamport clocks for sequential, conflict-free replicated versions.

func NewVersionManager

func NewVersionManager(conf config.ReplicaConfig) (v *VersionManager, err error)

NewVersionManager creates a new manager for handling lamport scalar versions.

func (VersionManager) Delete

func (v VersionManager) Delete(meta *pb.Object) error

Delete creates a tombstone version of the object in place.

func (VersionManager) Update

func (v VersionManager) Update(meta *pb.Object) error

Update the version of an object in place. If the object was previously a tombstone (e.g. deleted) then it is "undeleted".

Directories

Path Synopsis
Package iterator provides an interface and implementations to traverse over the contents of an embedded database while maintaining and reading replicated object metadata.
Package iterator provides an interface and implementations to traverse over the contents of an embedded database while maintaining and reading replicated object metadata.

Jump to

Keyboard shortcuts

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