sinkdb

package
v0.0.0-...-6d4bf48 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2023 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package sinkdb provides a strongly consistent key-value store.

Index

Constants

This section is empty.

Variables

View Source
var ErrConflict = errors.New("transaction conflict")

ErrConflict is returned by Exec when an instruction was not completed because its preconditions were not met.

Functions

This section is empty.

Types

type DB

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

DB provides access to an opened kv store.

func Open

func Open(laddr, dir string, httpClient *http.Client) (*DB, error)

Open initializes the key-value store and returns a database handle.

func (*DB) Close

func (db *DB) Close() error

Close closes the database handle releasing its resources. It is the caller's responsibility to ensure that there are no concurrent database operations in flight. Close is idempotent.

All other methods have undefined behavior on a closed DB.

func (*DB) Exec

func (db *DB) Exec(ctx context.Context, ops ...Op) error

Exec executes the provided operations after combining them with All.

func (*DB) Get

func (db *DB) Get(ctx context.Context, key string, v proto.Message) (Version, error)

Get performs a linearizable read of the provided key. The read value is unmarshalled into v.

func (*DB) GetStale

func (db *DB) GetStale(key string, v proto.Message) (Version, error)

GetStale performs a non-linearizable read of the provided key. The value may be stale. The read value is unmarshalled into v.

func (*DB) Ping

func (db *DB) Ping() error

Ping peforms an empty write to verify the connection to the rest of the cluster.

func (*DB) RaftService

func (db *DB) RaftService() *raft.Service

RaftService returns the raft service used for replication.

type Op

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

Op represents a change to the data store. Each Op starts with conditions, boolean predicates over existing stored data. If all conditions return true, the Op is said to be satisfied. It then results in zero or more effects, mutations to apply to the data. If an Op is unsatisfied, it has no effect. The zero value of Op is a valid operation with no conditions (it is always satisfied) and no effects.

func AddAllowedMember

func AddAllowedMember(addr string) Op

AddAllowedMember configures sinkdb to allow the provided address to participate in Raft.

func All

func All(op ...Op) Op

All encodes the atomic application of all its arguments.

The returned Op is satisfied if all arguments would be satisfied. Its effects (if satisfied) are the effects of the arguments.

func Delete

func Delete(key string) Op

Delete encodes a delete operation for key.

func Error

func Error(err error) Op

Error returns an Op representing an error condition. Exec will return err, and have no effect, when the returned Op is executed. If err is nil, Error returns the zero Op.

func IfNotExists

func IfNotExists(key string) Op

IfNotExists encodes a conditional to make an instruction successful only if the provided key does not exist.

func IfNotModified

func IfNotModified(v Version) Op

IfNotModified encodes a conditional to make an instruction successful only if the version stored in v's key matches v.

If v.Exists() is false, IfNotModified(v) is equivalent to IfNotExists(v.Key()).

func Set

func Set(key string, value proto.Message) Op

Set encodes a set operation setting key to value.

type Version

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

Version records the version of a particular key when it is read. Every time a key is set, its version changes.

func (Version) Exists

func (v Version) Exists() bool

Exists returns whether v's key exists when it was read.

func (Version) Key

func (v Version) Key() string

Key returns the key for which v is valid.

Directories

Path Synopsis
internal
sinkpb
Package sinkpb is a generated protocol buffer package.
Package sinkpb is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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