bbolt

package
v0.19.4 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package bbolt provides machine history tracking and traversal using the bbolt K/V database.

Index

Constants

View Source
const (
	BuckMachines    = "_machines"
	BuckTransitions = "transitions"
	BuckTimes       = "times"
)

Variables

This section is empty.

Functions

func DecTimeRecord

func DecTimeRecord(
	machId string, id uint64, v []byte, tryJson bool,
) (*amhist.TimeRecord, error)

func DecTransitionRecord

func DecTransitionRecord(
	machId string, id uint64, v []byte, tryJson bool,
) (*amhist.TransitionRecord, error)

func Decode

func Decode(v []byte, out any, tryJson bool) error

func GetMachine

func GetMachine(db *bbolt.DB, id string) (*amhist.MachineRecord, error)

GetMachine returns a machine record for a given machine id.

func ListMachines

func ListMachines(db *bbolt.DB) ([]*amhist.MachineRecord, error)

ListMachines returns a list of all machines in a database.

func NewDb

func NewDb(name string) (*bbolt.DB, error)

Types

type Config

type Config struct {
	amhist.BaseConfig
	EncJson bool
	// amount of records to save in bulk (default: 100)
	QueueBatch int32
}

type MatcherFn

type MatcherFn func(
	now *am.TimeIndex, machBucket *bbolt.Bucket,
) []*amhist.MemoryRecord

type Memory

type Memory struct {
	*amhist.BaseMemory

	Db *bbolt.DB
	// read-only config for this history
	Cfg            *Config
	SavePending    atomic.Int32
	SaveInProgress atomic.Bool
	Saved          atomic.Uint64
	// Value of Saved at the end of the last GC
	SavedGc atomic.Uint64
	// contains filtered or unexported fields
}

func NewMemory

func NewMemory(
	ctx context.Context, db *bbolt.DB, mach am.Api, cfg Config,
	onErr func(err error),
) (*Memory, error)

func (*Memory) Config

func (m *Memory) Config() amhist.BaseConfig

Config is amhist.BaseMemory.Config.

func (*Memory) Dispose

func (m *Memory) Dispose() error

Dispose is amhist.BaseMemory.Dispose. TODO merge with ctx

func (*Memory) FindLatest

func (m *Memory) FindLatest(
	ctx context.Context, retTx bool, limit int, query amhist.Query,
) ([]*amhist.MemoryRecord, error)

FindLatest is amhist.BaseMemory.FindLatest.

func (*Memory) Machine

func (m *Memory) Machine() am.Api

Machine is amhist.BaseMemory.Machine.

func (*Memory) MachineRecord

func (m *Memory) MachineRecord() *amhist.MachineRecord

MachineRecord is amhist.BaseMemory.MachineRecord.

func (*Memory) Match

func (m *Memory) Match(
	ctx context.Context, matcherFn MatcherFn,
) ([]*amhist.MemoryRecord, error)

Match returns the first record that matches the MatcherFn.

func (*Memory) Sync

func (m *Memory) Sync() error

Sync is amhist.BaseMemory.Sync.

Jump to

Keyboard shortcuts

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