store

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: AGPL-3.0 Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package store persists nerdui's own data in SQLite (ADR-0004).

Runtime objects (containers, images, ...) are never stored here: containerd and nerdctl stay the source of truth. Queries are written in SQL (queries/*.sql) and compiled into typed Go code by sqlc (package db); handlers never write SQL directly.

Index

Constants

View Source
const FileMode fs.FileMode = 0o600

FileMode is the permission of the database file; SQLite creates -wal/-shm with the same mode.

View Source
const FileName = "nerdui.db"

FileName is the database file inside the data directory.

Variables

View Source
var ErrNewerSchema = fmt.Errorf("database schema is newer than this nerdui build")

ErrNewerSchema is returned when the database was migrated by a newer nerdui.

Functions

func IsNotFound

func IsNotFound(err error) bool

IsNotFound reports whether err means "no rows".

func IsUniqueViolation

func IsUniqueViolation(err error) bool

IsUniqueViolation reports whether err is a UNIQUE or PRIMARY KEY constraint violation.

Types

type Option

type Option func(*Store)

Option configures Open.

func WithLogf

func WithLogf(logf func(format string, args ...any)) Option

WithLogf sets a logger for migration progress (default: discard).

type Store

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

Store holds a single-connection writer pool and a read-only reader pool.

func Open

func Open(ctx context.Context, dataDir string, opts ...Option) (*Store, error)

Open opens (creating if needed) <dataDir>/nerdui.db and applies pending migrations.

func (*Store) Close

func (s *Store) Close() error

Close closes both pools.

func (*Store) Path

func (s *Store) Path() string

Path returns the database file path.

func (*Store) Read

func (s *Store) Read() *db.Queries

Read returns queries bound to the read-only pool.

func (*Store) RewriteStackPaths added in v0.2.0

func (s *Store) RewriteStackPaths(ctx context.Context, from, to string) (int64, error)

RewriteStackPaths replaces the directory prefix from with to in the paths of registered stacks, after a restore to other directories (#89).

func (*Store) SchemaVersion

func (s *Store) SchemaVersion(ctx context.Context) (int64, error)

SchemaVersion returns the applied migration version.

func (*Store) Snapshot added in v0.2.0

func (s *Store) Snapshot(ctx context.Context, path string) error

Snapshot writes a consistent copy of the database to path with VACUUM INTO (#89). path must not exist.

func (*Store) Tx

func (s *Store) Tx(ctx context.Context, fn func(q *db.Queries) error) error

Tx runs fn in a write transaction, committing if fn returns nil.

func (*Store) Write

func (s *Store) Write() *db.Queries

Write returns queries bound to the single writer connection.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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