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
- Variables
- func IsNotFound(err error) bool
- func IsUniqueViolation(err error) bool
- type Option
- type Store
- func (s *Store) Close() error
- func (s *Store) Path() string
- func (s *Store) Read() *db.Queries
- func (s *Store) RewriteStackPaths(ctx context.Context, from, to string) (int64, error)
- func (s *Store) SchemaVersion(ctx context.Context) (int64, error)
- func (s *Store) Snapshot(ctx context.Context, path string) error
- func (s *Store) Tx(ctx context.Context, fn func(q *db.Queries) error) error
- func (s *Store) Write() *db.Queries
Constants ¶
const FileMode fs.FileMode = 0o600
FileMode is the permission of the database file; SQLite creates -wal/-shm with the same mode.
const FileName = "nerdui.db"
FileName is the database file inside the data directory.
Variables ¶
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 IsUniqueViolation ¶
IsUniqueViolation reports whether err is a UNIQUE or PRIMARY KEY constraint violation.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store holds a single-connection writer pool and a read-only reader pool.
func (*Store) RewriteStackPaths ¶ added in v0.2.0
RewriteStackPaths replaces the directory prefix from with to in the paths of registered stacks, after a restore to other directories (#89).
func (*Store) SchemaVersion ¶
SchemaVersion returns the applied migration version.
func (*Store) Snapshot ¶ added in v0.2.0
Snapshot writes a consistent copy of the database to path with VACUUM INTO (#89). path must not exist.