storeops

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package storeops runs the periodic operations that treat the bbolt file as an operational artifact rather than a set of rows: timestamped snapshots with retention pruning, and the file-size and freelist gauges.

Both were background goroutine bodies on Server. They read four things — the store, the metrics recorder, the live config, and the disk-full classifier — which is the same Deps-plus-a-live-config shape the scheduler package already takes, so they belong beside it rather than on the composition root. The two share a package because they share a subject: one writes the file, the other measures it, and both are the only code that cares how large it is.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Deps

type Deps struct {
	DB      store
	Metrics metrics
	// Cfg resolves the LIVE config each cycle, so enable, frequency, retention
	// and path changes take effect on the next iteration without a restart. It
	// returns nil in unconfigured mode, which the backup loop treats as disabled.
	Cfg func() *config.Config
	// RecordStoreWriteError classifies a write failure as a possible disk-full
	// condition. Injected rather than imported: the classifier needs the concrete
	// engine's error taxonomy, and this package names no engine.
	RecordStoreWriteError func(error)
}

Deps is what the runners need.

type Runner

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

Runner owns the periodic store-file operations.

func New

func New(deps Deps) *Runner

New returns a Runner over deps.

func (*Runner) RunBackup

func (r *Runner) RunBackup(ctx context.Context)

RunBackup periodically writes a database snapshot and prunes old backups until ctx is cancelled.

func (*Runner) RunMetrics

func (r *Runner) RunMetrics(ctx context.Context)

RunMetrics periodically reads the bbolt file size and freelist stats and records them as Prometheus gauges. It exits when ctx is cancelled.

Jump to

Keyboard shortcuts

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