templatedb

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Batch

type Batch interface {
	Set(key, value []byte) error
	Delete(key []byte) error
	WriteSync() error
	Close() error
}

Batch is the minimal batch interface used by templatedb.

type Config

type Config struct {
	MaxCandidatesPerFP    int
	MaxCandidateListBytes int
	MaxIDAttempts         int
}

Config controls templatedb storage behavior.

func NormalizeConfig

func NormalizeConfig(cfg Config) Config

NormalizeConfig applies defaults.

type KV

type KV interface {
	Get(key []byte) ([]byte, error)
	SetSync(key, value []byte) error
	DeleteSync(key []byte) error
	NewBatch() Batch
}

KV is the minimal public DB interface used by templatedb.

type Store

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

Store provides access to template storage backed by a TreeDB public DB.

func New

func New(kv KV, cfg Config) *Store

New wraps an existing public DB handle.

func (*Store) Close

func (s *Store) Close() error

Close closes the underlying store if it implements io.Closer.

func (*Store) GetCandidates

func (s *Store) GetCandidates(_ context.Context, fp uint64, max int) ([]template.Candidate, error)

GetCandidates loads the candidate list for a fingerprint.

func (*Store) GetTemplateDef

func (s *Store) GetTemplateDef(_ context.Context, id uint64) ([]byte, error)

GetTemplateDef loads TemplateDefBytes for a template ID.

func (*Store) PutTemplateDef

func (s *Store) PutTemplateDef(_ context.Context, defBytes []byte, routeFPs []uint64) (uint64, error)

PutTemplateDef stores a template definition and updates routing indices.

func (*Store) PutTemplateDefs

func (s *Store) PutTemplateDefs(_ context.Context, defs []template.PublishSpec) ([]uint64, error)

PutTemplateDefs stores multiple template definitions and updates routing indices in a single durable batch.

This is an optional acceleration used by the template engine when publishing bursts of templates; it is equivalent to calling PutTemplateDef for each template, but coalesces WriteSync.

Jump to

Keyboard shortcuts

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