kvs

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close() (err error)

Close closes the underlying rixxdb / dendrodb database connection, enabling the underlying database to clean up remainging transactions.

func Exit

func Exit(opts *cnf.Options) (err error)

Exit shuts down the connection with the data layer

func Export

func Export(w io.Writer) (err error)

Export saves all database operations to a writer. This can be used to save a database snapshot to a secondary file or stream.

func Import

func Import(r io.Reader) (err error)

Import loads database operations from a reader. This can be used to playback a database snapshot into an already running database.

func Register

func Register(name string, constructor func(*cnf.Options) (DB, error))

Register registers a new database type with the kvs package, enabling it's use as a backing datastore within SurrealDB.

func Setup

func Setup(opts *cnf.Options) (err error)

Setup sets up the connection with the data layer

Types

type DB

type DB interface {
	Begin(context.Context, bool) (TX, error)
	Import(io.Reader) error
	Export(io.Writer) error
	Close() error
}

DB represents a database implementation

type DBError

type DBError struct {
	Err error
}

DBError is an error which occurs when there is a problem with writing keys/values to the database.

func (*DBError) Error

func (e *DBError) Error() string

Error returns the string representation of the error.

type DS

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

DB represents a backing datastore.

func New

func New(opts *cnf.Options) (ds *DS, err error)

New sets up the underlying key-value store

func (*DS) Begin

func (ds *DS) Begin(ctx context.Context, writable bool) (txn TX, err error)

Begin begins a new read / write transaction with the underlying database, and returns the transaction, or any error which occured.

func (*DS) Close

func (ds *DS) Close() (err error)

Close closes the underlying rixxdb / dendrodb database connection, enabling the underlying database to clean up remainging transactions.

func (*DS) Export

func (ds *DS) Export(w io.Writer) (err error)

Export saves all database operations to a writer. This can be used to save a database snapshot to a secondary file or stream.

func (*DS) Import

func (ds *DS) Import(r io.Reader) (err error)

Import loads database operations from a reader. This can be used to playback a database snapshot into an already running database.

type KV

type KV interface {
	Exi() bool
	Key() []byte
	Val() []byte
	Ver() uint64
}

KV represents a database item

type TX

type TX interface {
	Closed() bool
	Cancel() error
	Commit() error

	All(context.Context, []byte) ([]KV, error)
	AllP(context.Context, []byte, uint64) ([]KV, error)
	AllR(context.Context, []byte, []byte, uint64) ([]KV, error)

	Clr(context.Context, []byte) (KV, error)
	ClrP(context.Context, []byte, uint64) ([]KV, error)
	ClrR(context.Context, []byte, []byte, uint64) ([]KV, error)

	Put(context.Context, int64, []byte, []byte) (KV, error)
	PutC(context.Context, int64, []byte, []byte, []byte) (KV, error)

	Get(context.Context, int64, []byte) (KV, error)
	GetP(context.Context, int64, []byte, uint64) ([]KV, error)
	GetR(context.Context, int64, []byte, []byte, uint64) ([]KV, error)

	Del(context.Context, int64, []byte) (KV, error)
	DelC(context.Context, int64, []byte, []byte) (KV, error)
	DelP(context.Context, int64, []byte, uint64) ([]KV, error)
	DelR(context.Context, int64, []byte, []byte, uint64) ([]KV, error)
}

TX represents a database transaction

func Begin

func Begin(ctx context.Context, writable bool) (txn TX, err error)

Begin begins a new read / write transaction with the underlying database, and returns the transaction, or any error which occured.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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