store

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package store defines the request pool's persistence boundary and provides a transactional Bolt implementation. Applications can implement Store to keep inventory in an existing database.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bolt

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

Bolt is a durable, single-process inventory store. Other processes cannot open the same file while it is in use. Opening a locked file fails after one second. Files are created with mode 0600 because endpoints may hold secrets.

func (*Bolt) Close

func (s *Bolt) Close() error

Close releases the file lock and closes the store.

func (*Bolt) LoadProxies

func (s *Bolt) LoadProxies(ctx context.Context) (Inventory, error)

LoadProxies reads an independent inventory snapshot, retaining exploration order.

func (*Bolt) Path

func (s *Bolt) Path() string

Path returns the path used to open the store.

func (*Bolt) SaveProxies

func (s *Bolt) SaveProxies(ctx context.Context, rows []Record, sources []Source, first json.RawMessage, retired map[string]float64) error

SaveProxies atomically replaces inventory, feeds, priors and retirement markers.

func (*Bolt) SaveProxy

func (s *Bolt) SaveProxy(ctx context.Context, row Record, first json.RawMessage) error

SaveProxy commits one outcome and its priors in one transaction. Updating an existing route does not rewrite the rest of the inventory.

type Inventory

type Inventory struct {
	Rows     []json.RawMessage
	Sources  []Source
	First    json.RawMessage
	Retired  map[string]float64
	Imported bool
}

Inventory is an ordered snapshot. First contains learned selection priors. Imported records whether an opted-in legacy import has already run.

type Record

type Record struct {
	URL  string
	Data json.RawMessage
}

Record is an endpoint's complete scored state, encoded as JSON by the pool.

type Source

type Source struct {
	URL   string
	Scope string
	Data  json.RawMessage
}

Source is a discovery feed's last listing for an optional scope.

type Store

type Store interface {
	LoadProxies(context.Context) (Inventory, error)
	SaveProxy(context.Context, Record, json.RawMessage) error
	SaveProxies(context.Context, []Record, []Source, json.RawMessage, map[string]float64) error
	Path() string
	Close() error
}

Store persists complete outcomes atomically with their learned priors. SaveProxies replaces the inventory, preserving the supplied row order. Implementations must not retain mutable references to supplied data.

func Open

func Open(ctx context.Context, path string) (Store, error)

Open opens a Bolt store without starting goroutines or contacting the network.

Jump to

Keyboard shortcuts

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