kvstoreadapter

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EnvOpenProfile selects the TreeDB profile for downstream wrappers.
	EnvOpenProfile = "TREEDB_OPEN_PROFILE"
	// EnvKeepRecent overrides the wrapper's KeepRecent default.
	EnvKeepRecent = "TREEDB_KEEP_RECENT"
	// EnvMemtableMode overrides the wrapper's memtable mode.
	EnvMemtableMode = "TREEDB_MEMTABLE_MODE"
)

Variables

This section is empty.

Functions

func ParseProfile deprecated

func ParseProfile(raw string, fallback treedb.Profile) treedb.Profile

ParseProfile parses the common downstream profile vocabulary and falls back to fallback for empty or unknown values.

Deprecated: use ParsePublicProfile at env/CLI boundaries that must reject deprecated TreeDB profiles.

func ParsePublicProfile

func ParsePublicProfile(raw string, fallback treedb.Profile) (treedb.Profile, error)

ParsePublicProfile parses the public downstream profile vocabulary. Empty input falls back to fallback, but the fallback must also be a public profile.

func ResolveOptions

func ResolveOptions(cfg OpenConfig) (treedb.Options, string, error)

ResolveOptions converts downstream wrapper defaults and standard TREEDB_* environment overrides into TreeDB Options.

Types

type OpenConfig

type OpenConfig struct {
	ParentDir string
	Name      string

	// AdapterName controls kvstore-facing Name() output.
	AdapterName string
	// DBFileSuffix defaults to ".db".
	DBFileSuffix string
	// DefaultProfile defaults to treedb.ProfileCommandWALRelaxed.
	DefaultProfile treedb.Profile
	// DefaultKeepRecent is applied when the env override is unset.
	DefaultKeepRecent uint64

	// DefaultMemtableMode applies when the env override is unset.
	DefaultMemtableMode string
	// DefaultAdaptiveMemtableBase maps an empty/adaptive profile default to
	// adaptive:<base> when DefaultMemtableMode is unset.
	DefaultAdaptiveMemtableBase string

	// Environment keys default to the standard TREEDB_* names when empty.
	ProfileEnvKey      string
	KeepRecentEnvKey   string
	MemtableModeEnvKey string

	// ReadWorkers overrides adapter read worker count when > 0.
	ReadWorkers int
}

OpenConfig standardizes the common "TreeDB behind a kvstore-style wrapper" open path used by downstream integrations such as cosmos-db/cometbft-db.

The intended usage is:

  1. Pick a TreeDB profile.
  2. Optionally pin a small KeepRecent window.
  3. Optionally allow an integration-specific memtable default/override.
  4. Open TreeDB and wrap it with the canonical kvstore adapter.

type Opened

type Opened struct {
	Path    string
	Options treedb.Options
	DB      *treedb.DB
	KV      *treedbadapter.DB
}

Opened is the standardized result returned to downstream wrappers.

func Open

func Open(cfg OpenConfig) (*Opened, error)

Open resolves standardized wrapper options, opens TreeDB, and returns the canonical kvstore adapter.

Jump to

Keyboard shortcuts

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