metakv

package
v0.1.12 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: Apache-2.0 Imports: 12 Imported by: 26

Documentation

Overview

Package metakv provides simple KV API to some "metadata store". In current implementation it is metadata store that keeps values in ns_server's ns_config.

Sub-namespace that is under directory "/checkpoints/" is going to be implemented specially. It is intended for xdcr checkpoints and will not be replicated between nodes in first version of this package.

Index

Constants

This section is empty.

Variables

View Source
var ErrRevMismatch = errors.New("Rev mismatch")

ErrRevMismatch error is returned from Set and Delete when there is rev mismatch

View Source
var RevCreate = &struct{}{}

RevCreate is a special revision which when passed to Set will change Set to Add.

Functions

func Add

func Add(path string, value []byte) error

Add creates given kv pair. Which must not exist in storage yet. ErrRevMismatch is returned if pair with such key exists.

func AddSensitive

func AddSensitive(path string, value []byte) error

AddSensitive is Add for storing sensitive info.

func Delete

func Delete(path string, rev interface{}) error

Delete deletes given key.

func ExecuteBasicSanityTest

func ExecuteBasicSanityTest(log func(v ...interface{}))

ExecuteBasicSanityTest runs basic sanity test.

func Get

func Get(path string) (value []byte, rev interface{}, err error)

Get returns matching value and revision for given key. Returns nil value, nil rev and nil error when given path doesn't exist.

func GoRunDebugEndpoint

func GoRunDebugEndpoint(listen string)

GoRunDebugEndpoint function can be used to run simple http server for "manual" debugging of metakv facility.

func IterateChildren

func IterateChildren(dirpath string, callback Callback) error

IterateChildren invokes given callback on every kv-pair that's child of given directory path. Path must end on "/".

func RecursiveDelete

func RecursiveDelete(dirpath string) error

RecursiveDelete deletes all keys that are children of given directory path.

func RunObserveChildren

func RunObserveChildren(dirpath string, callback Callback,
	cancel <-chan struct{}) error

RunObserveChildren invokes gen callback on every kv-pair that is child of given directory path and then on every mutation of affected keys. Deletions will be signalled by passing nil to value argument of callback. Returns only when cancel channel is closed or when children callback returns error. If exit is due to cancel channel being closed returned error is nil. Otherwise error is non-nil. Path must end on "/".

func Set

func Set(path string, value []byte, rev interface{}) error

Set updates given key-value pair. If non-nil, rev is a form of CAS value used to detect races with concurrent mutators in typical read-modify-write cases. Rev is supposed to be same value that is returned from get.

func SetSensitive

func SetSensitive(path string, value []byte, rev interface{}) error

SetSensitive is Set for storing sensitive info.

Types

type Callback

type Callback func(entry KVEntry) error

Callback type describes functions that receive mutations from RunObserveChildren.

type KVEntry

type KVEntry struct {
	Path      string
	Value     []byte
	Rev       interface{}
	Sensitive bool
}

KVEntry struct represents kv entry returned from ListAllChildren and used as a parameter in Callback

func ListAllChildren

func ListAllChildren(dirpath string) (entries []KVEntry, err error)

ListAllChildren returns all child entries of given "directory" node.

Jump to

Keyboard shortcuts

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