store

package
v0.1.0-alpha Latest Latest
Warning

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

Go to latest
Published: May 23, 2023 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultNamespace = "RedQueen"
	DefaultNamespace = ""
)
View Source
const KeyIndexNamespace string = "_KeyIndex"

Variables

View Source
var (
	ErrKeyAlreadyExists = errors.New("key already exists")
	ErrKeyNotFound      = errors.New("key not found")
)

Functions

This section is empty.

Types

type Base

type Base interface {
	GetNamespace() string
	Get(key []byte) (value *Value, err error)
	SetWithTTL(key, value []byte, ttl uint32) error
	TrySetWithTTL(key, value []byte, ttl uint32) error
	Set(key, value []byte) error
	// TrySet try to set a key-value, returns an error if the key already exists
	TrySet(key, value []byte) error
	Del(key []byte) error
	Watch(key []byte) (notify WatcherNotify, err error)
}

type KeyIndex

type KeyIndex struct {
	NodeID    int64  `msgpack:"nid"`
	Namespace string `msgpack:"ns"`
	Key       []byte `msgpack:"key"`
}

func NewKeyIndex

func NewKeyIndex(nodeID int64, namespace string, key []byte) *KeyIndex

func (*KeyIndex) FullPath

func (i *KeyIndex) FullPath() []byte

func (*KeyIndex) Hash

func (i *KeyIndex) Hash() []byte

type Namespace

type Namespace Base

type Store

type Store interface {
	Base
	Namespace(namespace string) (Namespace, error)
	Close() error
	// Snapshot should be in tar & gzip format
	Snapshot() (io.Reader, error)
	Break(context.Context) error
}

type Value

type Value struct {
	Data []byte
}

func NewValue

func NewValue(data []byte) *Value

type WatchValue

type WatchValue struct {
	Seq       uint64
	Timestamp int64
	// Data can be nil pointer, if Data is nil pointer then that the Data is deleted
	Data *[]byte
}

func (*WatchValue) Deleted

func (v *WatchValue) Deleted() bool

type WatcherNotify

type WatcherNotify interface {
	Notify() chan *WatchValue
	Close() error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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