dbview

package
v1.34.0-beta.3 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package dbview assembles the Databases surface: which installed services are database engines, the databases inside each one with their sizes, the site that owns each database, and the snapshots it holds. The web UI and the TUI both render from here so the two can never disagree about what a database belongs to.

Index

Constants

View Source
const TestingSuffix = "_testing"

TestingSuffix names the paired testing database lerd creates alongside every project database.

Variables

This section is empty.

Functions

func InstalledEngines

func InstalledEngines() []string

InstalledEngines returns the installed database-engine service names, both default-stack (mysql, postgres) and add-on (mariadb, mongo, postgres-pgvector). sqlite is a file-based engine with no container, so it is excluded.

func IsEngine

func IsEngine(name string) bool

IsEngine reports whether a service belongs on the Databases surface: a family lerd wires as a project database, or any engine whose preset declares databases it can enumerate. The second half is what lets the store publish an engine outside the wired families (an analytics column store, say) and have it appear with the operations it declares.

func SiteIndexes

func SiteIndexes() map[string]map[string]Owner

SiteIndexes maps each engine to the databases owned in it, keyed by database name, resolved through each site's framework declaration and from the isolated databases worktrees have registered. A "<db>_testing" database maps to the same owner as "<db>", so both link to the same place. When a group shares one database across a main site and its secondaries, the database belongs to the group main, so a secondary that merely shares it never wins over the main.

Every engine is answered from one pass over the sites: resolving a site's targets detects its framework, which is far too much work to repeat per engine on every poll of the Databases tab.

Types

type Engine

type Engine struct {
	Service          string
	Family           string
	Running          bool
	SupportsSnapshot bool
	Databases        []Entry
	Error            string
}

Engine is one database engine with the databases it holds. Error carries an introspection failure so the surface can say why an engine came back empty.

func Load

func Load(name string, siteIndex map[string]Owner) Engine

Load builds one engine's view, introspecting its databases and snapshots only when the container is running. siteIndex is that engine's slice of SiteIndexes; pass nil to leave owners unresolved.

func LoadAll

func LoadAll() []Engine

LoadAll builds the whole surface: every installed engine with its databases, resolved against one pass over the sites.

type Entry

type Entry struct {
	Name      string
	SizeBytes int64
	Owner     Owner
	Snapshots []serviceops.Snapshot
}

Entry is a single database with its size, its owning site and the snapshots taken of it.

type Owner

type Owner struct {
	Domain string
	Branch string
}

Owner is the site a database belongs to: the parent site's domain, plus the branch when the database is a worktree's isolated one. The branch is what turns "astrolov_staging" into staging.astrolov.test in the UI.

Jump to

Keyboard shortcuts

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