storage

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package storage is the embedded-database foundation for Jōei's persistent state. It wraps a pure-Go SQLite *sql.DB (modernc.org/sqlite, no cgo) with sensible PRAGMAs and a small per-component migration helper, so several subsystems (telemetry now, runtime settings later) can share one file and version their schema independently.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

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

DB wraps a SQLite connection pool configured for Jōei's persistence needs.

func Open

func Open(path string) (*DB, error)

Open opens (or creates) the SQLite database at path, creating the parent directory if needed, and applies the baseline PRAGMAs (WAL for non-blocking reads, a busy timeout to tolerate brief contention). A single open connection keeps writes serialized, matching internal/cache.

func (*DB) ApplyMigrations

func (d *DB) ApplyMigrations(component string, steps []string) error

ApplyMigrations runs the ordered migration steps for a named component, tracking how many have been applied in a schema_migrations table so each component versions independently on the shared file. Forward-only and idempotent: steps already applied (index < stored version) are skipped.

func (*DB) Close

func (d *DB) Close() error

Close closes the database.

func (*DB) SQL

func (d *DB) SQL() *sql.DB

SQL returns the underlying *sql.DB for components to run their queries.

type WriterStats added in v1.1.0

type WriterStats struct {
	Capacity, Queued, InFlight, UnsavedItems, LastBatchSize             int64
	AttemptedItems, AcceptedItems, DroppedFullItems, DroppedClosedItems uint64
	AbandonedItems, CommittedItems, Batches, Failures, Retries          uint64
	OldestAge, LastSuccessAge, CommitTimeTotal, LastCommitDuration      time.Duration
}

WriterStats is an in-memory observation of a background writer. Item counts mean events for telemetry and hits for usage; queue/batch sizes mean rows.

Directories

Path Synopsis
Package storagetest provides test helpers for SQLite-backed tests.
Package storagetest provides test helpers for SQLite-backed tests.

Jump to

Keyboard shortcuts

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