driver

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2022 License: BSD-3-Clause Imports: 4 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

This section is empty.

Types

type BatchDB

type BatchDB interface {
	DB
	NewBatch() Batching
}

type Batching

type Batching interface {
	Writer
	Commit() error
}

type Configure

type Configure interface {
	Options(opts ...Option) (exported map[string]struct{})
}

type Cursor

type Cursor interface {
	Next() bool
	Prev() bool
	Last() bool
	Seek(key Key) bool
	Key() []byte
	Value() []byte
	Valid() bool
	Error() error
	io.Closer
}

type DB

type DB interface {
	Schema
	Reader
	Writer
	Finder
	GetSnapshot() (Snapshot, error)
	io.Closer
}

type Driver

type Driver interface {
	Open(dsn, options string) (DB, error)
}

type FieldSpec

type FieldSpec struct {
	Name string `json:"name,omitempty"`
	Type string `json:"type"`
}

FieldSpec holds information about a particular field.

type Finder

type Finder interface {
	Search(query Query) Cursor
}

type IndexSpec

type IndexSpec struct {
	Name   string `json:"name"`
	Prefix []byte `json:"prefix"`
}

IndexSpec holds information about a particular index. It does not contain index type, as indexes do not have type.

type Key

type Key struct {
	Prefix int
	Data   []byte
}

type Option

type Option interface {
	Identity() string
	Value() interface{}
	Exported() bool
}

type OptionValue

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

func NewOption

func NewOption(key string, initial interface{}, export bool) *OptionValue

func (*OptionValue) Exported added in v1.3.0

func (ov *OptionValue) Exported() bool

func (*OptionValue) Identity

func (ov *OptionValue) Identity() string

func (*OptionValue) Set

func (ov *OptionValue) Set(v interface{})

func (*OptionValue) Value

func (ov *OptionValue) Value() interface{}

type Query

type Query struct {
	Prefix      Key
	MatchPrefix bool
}

type Reader

type Reader interface {
	Get(key Key) ([]byte, error)
	Has(key Key) (bool, error)
}

type Schema

type Schema interface {
	DefaultFieldKey() []byte
	DefaultIndexKey() []byte
	InitSchema() error
	GetSchemaSpec() (SchemaSpec, error)
	CreateField(spec FieldSpec) ([]byte, error)
	CreateIndex(spec IndexSpec) ([]byte, error)
	RenameIndex(oldName, newName string) (bool, error)
}

type SchemaSpec

type SchemaSpec struct {
	Fields  []FieldSpec `json:"fields"`  // keys are field names
	Indexes []IndexSpec `json:"indexes"` // keys are index prefix bytes
}

SchemaSpec is used to serialize known database structure information.

type Snapshot

type Snapshot interface {
	Reader
	io.Closer
}

type Transaction

type Transaction interface {
	Writer
	Commit() error
	Rollback() error
}

type TxnDB

type TxnDB interface {
	DB
	NewTransaction() Transaction
}

type Value

type Value struct {
	Data []byte
}

type Writer

type Writer interface {
	Put(key Key, value Value) error
	Delete(key Key) error
}

Jump to

Keyboard shortcuts

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