kv

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package kv is the small durable key-value store used for agent metadata: alert state, log offsets, bundle state, key manifest sequence, cursors.

Index

Constants

This section is empty.

Variables

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

ErrNotFound is returned by helpers that require a key.

Functions

func OpenBolt

func OpenBolt(path string) (*bolt.DB, error)

OpenBolt opens (creating) a bbolt file. The caller holds any directory lock.

Types

type Bolt

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

Bolt is a Store backed by one bbolt bucket.

func NewBolt

func NewBolt(db *bolt.DB, bucket string) (*Bolt, error)

NewBolt returns a Store over bucket in db, creating the bucket.

func (*Bolt) Batch

func (s *Bolt) Batch(ops map[string][]byte) error

func (*Bolt) Delete

func (s *Bolt) Delete(key string) error

func (*Bolt) ForEach

func (s *Bolt) ForEach(prefix string, fn func(string, []byte) error) error

func (*Bolt) Get

func (s *Bolt) Get(key string) ([]byte, bool, error)

func (*Bolt) Put

func (s *Bolt) Put(key string, value []byte) error

type Memory

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

Memory is an in-memory Store for tests and ephemeral use.

func NewMemory

func NewMemory() *Memory

NewMemory returns an empty in-memory store.

func (*Memory) Batch

func (s *Memory) Batch(ops map[string][]byte) error

func (*Memory) Delete

func (s *Memory) Delete(key string) error

func (*Memory) ForEach

func (s *Memory) ForEach(prefix string, fn func(string, []byte) error) error

func (*Memory) Get

func (s *Memory) Get(key string) ([]byte, bool, error)

func (*Memory) Put

func (s *Memory) Put(key string, value []byte) error

type Prefixed

type Prefixed struct {
	S      Store
	Prefix string
}

Prefixed scopes a Store under a key prefix.

func (Prefixed) Batch

func (p Prefixed) Batch(ops map[string][]byte) error

func (Prefixed) Delete

func (p Prefixed) Delete(k string) error

func (Prefixed) ForEach

func (p Prefixed) ForEach(prefix string, fn func(string, []byte) error) error

func (Prefixed) Get

func (p Prefixed) Get(k string) ([]byte, bool, error)

func (Prefixed) Put

func (p Prefixed) Put(k string, v []byte) error

type Store

type Store interface {
	Get(key string) ([]byte, bool, error)
	Put(key string, value []byte) error
	Delete(key string) error
	// ForEach visits keys with prefix in ascending order.
	ForEach(prefix string, fn func(key string, value []byte) error) error
	// Batch applies puts (nil value deletes) atomically.
	Batch(ops map[string][]byte) error
}

Store is a durable key-value namespace. Writes are durable when they return.

Jump to

Keyboard shortcuts

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