libkv

package
v0.0.0-...-65c93a7 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

	ErrInvalidValue = errors.New("invalid value for operation")
	ErrKeyExists    = errors.New("key already exists")
)

Functions

func SetupLocalPDInstance

func SetupLocalPDInstance(ctx context.Context) (string, testcontainers.Container, func(), error)

func SetupLocalTiKVInstance

func SetupLocalTiKVInstance(ctx context.Context) (string, testcontainers.Container, func(), error)

func SetupLocalValKeyInstance

func SetupLocalValKeyInstance(ctx context.Context) (string, testcontainers.Container, func(), error)

Types

type KVExec

type KVExec interface {
	Get(ctx context.Context, key []byte) ([]byte, error)
	Set(ctx context.Context, keyvalue KeyValue) error
	Delete(ctx context.Context, key []byte) error
	Exists(ctx context.Context, key []byte) (bool, error)
	List(ctx context.Context) ([]string, error)
}

KVExec represents the basic key-value operations.

type KVManager

type KVManager interface {
	Operation(ctx context.Context) (KVExec, error)
	// Close shuts down the underlying key-value store.
	Close() error
}

KVManager provides an interface to work with the key-value store.

func NewNatsKVManager

func NewNatsKVManager(url, bucketName string, create bool) (KVManager, error)

NewNatsKVManager creates a new KVManager backed by a NATS JetStream Key-Value store. 'url' is the NATS server address and 'bucketName' is the name of the KV bucket.

type KeyValue

type KeyValue struct {
	Key   []byte
	Value []byte
}

Jump to

Keyboard shortcuts

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