Documentation
¶
Overview ¶
Package setup holds the onboarding and configuration services: the documents the local API returns and the pure reads that build the same documents from state files when no server is running. Presentations (CLI, TUI, web) render these documents; they never compute next actions, order or validation themselves.
See decision 0006 and spec/features/configuration-parity#REQ:json-equals-api.
Index ¶
- Constants
- Variables
- func ApplyTelemetryChange(dirs paths.Dirs, change telemetry.Change, channel telemetry.Channel, ...) (telemetry.Consent, bool, error)
- func BootstrapNext() []envelope.Next
- func CatalogueDir(home string) string
- func ConnectedNext(database Database, gitIdentityMissing bool) []envelope.Next
- func ConnectedStored(database Database) string
- func CreatedNext(database Database) []envelope.Next
- func DatabaseIDs(databases []Database) []string
- func DefaultPath(dataHome, engine, id string) string
- func DemoLocation(dataHome, id string) string
- func EnvironmentNames(m *manifest.Manifest) []string
- func EnvironmentValues(m *manifest.Manifest, getenv func(string) string) []string
- func FallbackAddress(port int) string
- func ForgetDemo(home, id string) error
- func GitIdentityMissing(ctx context.Context, dir string) bool
- func GitIdentityNext() []envelope.Next
- func HasCreateDBCapability(caps []string) bool
- func Location(m *manifest.Manifest, baseDir string) string
- func ManifestPath(home, id string) string
- func ManifestSteps(engine string) []envelope.Next
- func MountsPath(runtimeDir string) string
- func NormalizeOrigins(origins []string) []string
- func ParseOrigins(value string) ([]string, *envelope.Error)
- func ParsePort(value, source string) (int, *envelope.Error)
- func PrimaryAddress(port int) string
- func RecordDemo(home string, record DemoRecord) error
- func RegistryDir(home string) string
- func ReloadedNext(database Database) []envelope.Next
- func ResolvePort(flagPort int, getenv paths.Getenv, config Config) (port int, explicit bool, err *envelope.Error)
- func SameLocation(a, b string) bool
- func ScopeCapabilities(scope string) ([]string, error)
- func SuggestedName(next envelope.Next) string
- func TelemetryConfirmationRequired() *envelope.Error
- func UnknownConfigKey(key string) *envelope.Error
- func ValidPort(port int) bool
- func ValidateConnect(request *ConnectRequest) *envelope.Error
- func ValidateCreate(request *CreateRequest) *envelope.Error
- func WriteMounts(runtimeDir string, mounts Mounts) error
- type Badge
- type Config
- type ConfigChange
- type ConfigDocument
- type ConnectRequest
- type CopyRef
- type CreateRequest
- type Database
- type DatabaseResult
- type DatabasesDocument
- type DemoRecord
- type DemoStatus
- type Engine
- type EnginesDocument
- type HomeDocument
- type HomeOption
- type MountRecord
- type Mounter
- type Mounts
- type Registration
- type Registry
- func (r *Registry) AwaitMount(ctx context.Context, id string)
- func (r *Registry) Close()
- func (r *Registry) Connect(request ConnectRequest) (DatabaseResult, error)
- func (r *Registry) Create(request CreateRequest) (DatabaseResult, error)
- func (r *Registry) GitStorage(id string) (string, bool)
- func (r *Registry) List() ([]Database, error)
- func (r *Registry) MountAll(ctx context.Context)
- func (r *Registry) Mounts() *Mounts
- func (r *Registry) Reconnect(request CreateRequest) (DatabaseResult, error)
- func (r *Registry) Reload(ctx context.Context, id string) (DatabaseResult, error)
- func (r *Registry) ReloadAll(ctx context.Context) (DatabasesDocument, error)
- func (r *Registry) Remove(ctx context.Context, id string) (DatabaseResult, error)
- type RegistryOptions
- type Server
- type ServerConfig
- type ServerDocument
- type Status
- type StatusTelemetry
- type TelemetryOutcome
Constants ¶
const ( KeyServerPort = "server.port" // KeyServerCORS lists the browser app origins allowed to call /v1/… and // /token with bearer tokens (capability 25, CLI only: exception E7). KeyServerCORS = "server.cors" // KeyServerReadOnly rejects database mutations for this server, including // requests authenticated with the owner token. It applies on the next // server start. KeyServerReadOnly = "server.read_only" )
Configuration keys. Telemetry and the global context follow in later increments.
const ( MinPort = 1 MaxPort = 65535 )
MinPort and MaxPort bound every port ovdb accepts, from a flag, an environment variable, `ovdb config set server.port` or the TUI's own pre-submit check — one place so the range cannot drift between them.
const ( // UnmountTimeout bounds the wait for in-flight requests when a database // is removed, reloaded or the server stops. UnmountTimeout = 10 * time.Second // DefaultMountTimeout bounds one database's mount. DefaultMountTimeout = 5 * time.Second )
Timeouts.
const ( ActionEditName = "edit_name" ActionEditLocation = "edit_location" ActionDatabases = "databases" ActionDone = "done" // ActionUse makes the database current: for this project in the TUI, // as the default for all projects in the web console (parity E3). ActionUse = "use" // ActionBrowse opens Browse data for the database. ActionBrowse = "browse" )
Next actions presentations can act on in place (envelope.Next.Action). For edit_name, a command naming a database (`ovdb databases create notes-2`) carries the suggested name: see SuggestedName.
const ( DemoDefaultID = "todo" DemosDir = "demos" // DemosFile, in OVDB home, records every demo install wrote: the demo is // the database registered with that id at that place, never whatever // happens to live in a folder named demos. DemosFile = "demos.json" )
The built-in TODO demo's database id and folder (spec/features/todo-demo). The demo service lives in internal/setup/demo; the status document only needs to find an installed demo, so that part is here.
const ( EngineInGitDB = "ingitdb" EngineSQLite = "sqlite" EngineFirestore = "firestore" EngineMySQL = "mysql" EnginePostgres = "postgres" )
Engine ids. They are the storage.engine values the manifest parser and openvaultdb-go's mount accept; engines_test.go fails when the two drift.
const ( SetupGuided = "guided" SetupManifest = "manifest" )
Setup kinds: an engine is created and connected in guided steps, or set up with a manifest file only (database-setup-and-providers#REQ:manifest-only-engines-are-honest).
const ( // DatabasesDir holds one manifest per registered database, <id>.yaml. DatabasesDir = "databases" // CataloguesDir holds the inferred-schema catalogues OVDB keeps for // registered databases, so mounting never writes into user storage. CataloguesDir = "catalogues" // MountsFile is the running server's per-database mount state. MountsFile = "mounts.json" )
Registry locations inside OVDB home and the runtime directory.
const ( MountMounting = "mounting" // loading after a start or reload MountMounted = "mounted" MountNeedsAttention = "needs_attention" MountUnknown = "unknown" // no server running )
Mount states.
const ( StateRunning = "running" StateNotRunning = "not_running" StateStopping = "stopping" // only in the shutdown response )
Server states.
const ( ScopeReadOnly = "read-only" ScopeReadWrite = "read-write" ScopeCreateDB = "create-db" )
Token scopes: the capability sets `ovdb token create --scope` names.
const ActionEditManifest = "edit_manifest"
ActionEditManifest is the next action that returns to the manifest path.
const ConfigFile = "config.yaml"
ConfigFile is the configuration file in OVDB home.
const EnvPort = "OVDB_PORT"
EnvPort overrides the configured port for one shell.
const GitIdentityMissingCode = "git_identity_missing"
GitIdentityMissingCode is the /v1 error code local mode adds for a write that Git could not commit for want of a name and email.
const InGitDBDir = ".ingitdb"
InGitDBDir is the folder that makes a folder an inGitDB database.
const ManifestDocsURL = "https://github.com/openvaultdb/openvaultdb-go#manifest-examples"
ManifestDocsURL explains manifests, engines and schema modes.
const SchemaDocsURL = "https://github.com/openvaultdb/openvaultdb-go#schema-modes"
SchemaDocsURL explains schema modes and how to declare collections.
Variables ¶
var Keys = []string{KeyServerPort, KeyServerCORS, KeyServerReadOnly}
Keys lists the supported keys, for usage errors.
Functions ¶
func ApplyTelemetryChange ¶ added in v0.18.0
func ApplyTelemetryChange(dirs paths.Dirs, change telemetry.Change, channel telemetry.Channel, now time.Time) (telemetry.Consent, bool, error)
ApplyTelemetryChange is ChangeTelemetry without the backup path.
func BootstrapNext ¶ added in v0.17.0
BootstrapNext is what non-interactive bare `ovdb` offers, always all five (first-run-onboarding#REQ:bare-ovdb-non-interactive): set up in the terminal, in the browser or with commands, try the demo, or install the storage skill after asking the person.
func CatalogueDir ¶ added in v0.11.0
CatalogueDir is <home>/catalogues.
func ConnectedNext ¶ added in v0.14.0
ConnectedNext is what to do after connecting database: first how to let Git save changes when it cannot, then what a created database offers.
func ConnectedStored ¶ added in v0.14.0
ConnectedStored is where a connected database's data stays, as every interface says it. For SQLite it also says the whole file is readable: the manifest describes tables, but reads reach every table and column (openvaultdb-go serves the file as a whole).
func CreatedNext ¶ added in v0.11.0
CreatedNext is what to do after creating database: for SQLite, describing the data comes before anything that writes (database-setup-and-providers#REQ:sqlite-next-step-is-schema).
func DatabaseIDs ¶ added in v0.11.0
DatabaseIDs are the ids of databases, in order.
func DefaultPath ¶ added in v0.11.0
DefaultPath is where a new database lives unless the person picks another place: <data home>/<id>/ for inGitDB, <data home>/<id>.sqlite for SQLite (database-setup-and-providers#REQ:create-new-database). Clients call it with the data home they resolved.
func DemoLocation ¶ added in v0.12.0
DemoLocation is where database id keeps the demo under dataHome: <data home>/demos/<id>.
func EnvironmentNames ¶ added in v0.14.0
EnvironmentNames are the environment variables m takes values from: every *_env field (dsn_env, token_env, …) and the defaults that apply when one is left out.
func EnvironmentValues ¶ added in v0.14.0
EnvironmentValues are the values of m's named variables in getenv, the secrets a message about m must never show.
func FallbackAddress ¶
FallbackAddress is the address that works where *.localhost does not.
func ForgetDemo ¶ added in v0.12.0
ForgetDemo removes the record for database id, if any.
func GitIdentityMissing ¶ added in v0.14.0
GitIdentityMissing reports whether dir is a Git working tree where a commit would fail because Git has no name or email for this user, so inGitDB writes there would fail. OVDB never sets one in a person's folder; it says how to set their own.
func GitIdentityNext ¶ added in v0.14.0
GitIdentityNext is how to give Git a name and email.
func HasCreateDBCapability ¶ added in v0.13.0
HasCreateDBCapability reports whether caps contains databases:create (a server-level token needs no database).
func Location ¶ added in v0.11.0
Location describes where m keeps its data without any credential: the absolute storage path, or for server engines where the connection comes from. baseDir resolves relative paths.
func ManifestPath ¶ added in v0.11.0
ManifestPath is where database id is registered.
func ManifestSteps ¶ added in v0.11.0
ManifestSteps is how to set up a manifest-only engine: write a manifest, edit it and connect it (database-setup-and-providers#REQ:manifest-only-engines-are-honest).
func MountsPath ¶ added in v0.11.0
MountsPath is <runtime>/mounts.json.
func NormalizeOrigins ¶ added in v0.9.0
NormalizeOrigins cleans origins read from a hand-edited config.yaml the way ParseOrigins cleans CLI input, dropping entries that are not origins (and a trailing slash, which browsers never send).
func ParseOrigins ¶ added in v0.9.0
ParseOrigins parses a comma-separated list of browser origins (scheme://host[:port], http or https, nothing after the host). An empty value clears the list.
func ParsePort ¶
ParsePort validates a port number given through source (a flag, variable or key name).
func PrimaryAddress ¶
PrimaryAddress is the address people open.
func RecordDemo ¶ added in v0.12.0
func RecordDemo(home string, record DemoRecord) error
RecordDemo adds or replaces the record for record.Database. Only the server holding home.lock calls it.
func RegistryDir ¶ added in v0.11.0
RegistryDir is <home>/databases.
func ReloadedNext ¶ added in v0.11.0
ReloadedNext is what to do after a reload.
func ResolvePort ¶
func ResolvePort(flagPort int, getenv paths.Getenv, config Config) (port int, explicit bool, err *envelope.Error)
ResolvePort applies --port > OVDB_PORT > server.port > 6832 (REQ:port-precedence). explicit is true for the flag and the variable, which must match a running server's port.
func SameLocation ¶ added in v0.12.0
SameLocation reports whether two absolute locations name the same place, ignoring case where the file system usually does.
func ScopeCapabilities ¶ added in v0.13.0
ScopeCapabilities maps a token scope to its capabilities; "" is read-write.
func SuggestedName ¶ added in v0.11.0
SuggestedName is the name an edit_name next action suggests, or "".
func TelemetryConfirmationRequired ¶ added in v0.18.0
TelemetryConfirmationRequired is enabling without the person's yes. It is only ever returned where no one could be asked (no terminal, an agent, the local API), so it says to ask the person and then pass --confirmed-by-user, and offers no command: the one that failed would fail again (review L2). A person in a terminal is asked instead.
func UnknownConfigKey ¶
UnknownConfigKey is invalid_argument naming the supported keys.
func ValidateConnect ¶ added in v0.14.0
func ValidateConnect(request *ConnectRequest) *envelope.Error
ValidateConnect checks a request without touching anything, fills the default engine and cleans its paths with this OS's rules.
func ValidateCreate ¶ added in v0.11.0
func ValidateCreate(request *CreateRequest) *envelope.Error
ValidateCreate checks a request without touching anything. It fills the default engine and normalizes the location with this OS's path rules (so C:/Users/… is absolute on Windows, and a trailing separator is fine).
func WriteMounts ¶ added in v0.11.0
WriteMounts atomically writes mounts.json owner-only.
Types ¶
type Badge ¶ added in v0.9.0
type Badge struct {
Tone string `json:"tone"` // ok, warn, neutral
LabelKey string `json:"label_key"`
}
Badge is a server state as presentations show it: a tone and a copy key.
func StateBadge ¶ added in v0.9.0
StateBadge maps a server state to its badge.
type Config ¶
type Config struct {
Server ServerConfig `yaml:"server,omitempty" json:"server"`
// Telemetry is the consent state, read and changed only through
// `ovdb telemetry` and /api/local/v1/telemetry (telemetry-consent
// #REQ:opt-in-state), so it is not part of the config document.
Telemetry telemetry.Consent `yaml:"telemetry,omitempty" json:"-"`
}
Config is config.yaml. Unset values are omitted and mean "default".
func LoadConfig ¶
LoadConfig reads config.yaml; a missing file is the empty configuration.
type ConfigChange ¶
ConfigChange is the body of PUT /api/local/v1/config.
type ConfigDocument ¶
type ConfigDocument struct {
Schema int `json:"schema"`
Config Config `json:"config"`
// Changed is set on a change's result: false when the value was
// already the one asked for, so nothing needs a restart.
Changed *bool `json:"changed,omitempty"`
Next []envelope.Next `json:"next"`
}
ConfigDocument is the body of GET/PUT /api/local/v1/config and the --json output of `ovdb config get|set`.
func ApplyConfigChange ¶
func ApplyConfigChange(dirs paths.Dirs, change ConfigChange, serverRunning bool) (ConfigDocument, error)
ApplyConfigChange validates change, writes config.yaml owner-only and returns the resulting document. The caller must be the home's single writer: the running server, or a client holding home.lock (serverRunning false).
func NewConfigDocument ¶
func NewConfigDocument(config Config, changedWhileRunning bool) ConfigDocument
NewConfigDocument wraps config. A change made while the server runs gets the restart that applies it as its next action.
type ConnectRequest ¶ added in v0.14.0
type ConnectRequest struct {
ID string `json:"id,omitempty"`
Engine string `json:"engine,omitempty"`
Path string `json:"path,omitempty"`
Manifest string `json:"manifest,omitempty"`
}
ConnectRequest is the body of POST /api/local/v1/databases/connect: an existing inGitDB folder or SQLite file (ID, Engine and Path), or a manifest file (Manifest alone) that names its database and storage (database-setup-and-providers#REQ:connect-existing-storage, REQ:connect-with-manifest). Paths are absolute: the client resolves them.
type CopyRef ¶ added in v0.9.0
CopyRef is copy a presentation renders: a catalogue key and its params.
func ContextStatus ¶ added in v0.11.0
ContextStatus is the status line part naming the current database and its scope (first-run-onboarding#REQ:home-status-line).
func DatabasesStatus ¶ added in v0.11.0
DatabasesStatus is the status line part counting databases and how many need attention (first-run-onboarding#REQ:home-status-line).
type CreateRequest ¶ added in v0.11.0
type CreateRequest struct {
ID string `json:"id"`
Engine string `json:"engine"`
Path string `json:"path"`
}
CreateRequest is the body of POST /api/local/v1/databases. Path is the absolute location the client resolved (by default under its data home).
type Database ¶ added in v0.11.0
type Database struct {
ID string `json:"id"`
Engine string `json:"engine,omitempty"`
Location string `json:"location,omitempty"`
State string `json:"state,omitempty"` // mounted, needs_attention, unknown
// Reason says, redacted, why a database needs attention.
Reason string `json:"reason,omitempty"`
// Manifest is the registry file, so a person can inspect or fix it.
Manifest string `json:"manifest"`
}
Database is one registered database as every interface lists it.
type DatabaseResult ¶ added in v0.11.0
type DatabaseResult struct {
Schema int `json:"schema"`
Database Database `json:"database"`
Next []envelope.Next `json:"next"`
}
DatabaseResult is the body of a successful create, reload or remove, and the --json output of `ovdb databases create|reload|remove`.
func NewRemovedResult ¶ added in v0.11.0
func NewRemovedResult(database Database) DatabaseResult
NewRemovedResult is the result of removing database.
type DatabasesDocument ¶ added in v0.11.0
type DatabasesDocument struct {
Schema int `json:"schema"`
Databases []Database `json:"databases"`
Next []envelope.Next `json:"next"`
}
DatabasesDocument is the body of GET /api/local/v1/databases and the --json output of `ovdb databases`.
func NewDatabasesDocument ¶ added in v0.11.0
func NewDatabasesDocument(databases []Database) DatabasesDocument
NewDatabasesDocument wraps databases with the next actions that apply.
type DemoRecord ¶ added in v0.12.0
type DemoRecord struct {
App string `json:"app"`
Database string `json:"database"`
Location string `json:"location"`
}
DemoRecord is one demo install: its app, database id and folder.
func DemoRecordFor ¶ added in v0.12.0
func DemoRecordFor(home, location string) (DemoRecord, bool)
DemoRecordFor is the recorded install at location, if any.
func ReadDemos ¶ added in v0.12.0
func ReadDemos(home string) []DemoRecord
ReadDemos lists the recorded demo installs; a missing or unreadable file is none.
type DemoStatus ¶ added in v0.12.0
type DemoStatus struct {
Installed bool `json:"installed"`
Database string `json:"database,omitempty"`
Location string `json:"location"`
}
DemoStatus is the demo field group of the status document (first-run-onboarding#REQ:status-command).
func NewDemoStatus ¶ added in v0.12.0
func NewDemoStatus(dirs paths.Dirs, databases []Database) DemoStatus
NewDemoStatus describes the demo among databases, or where it would go.
type Engine ¶ added in v0.11.0
type Engine struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
SchemaModes []string `json:"schema_modes"`
// Pinned engines come first, in catalogue order, and presentations
// separate them from the rest.
Pinned bool `json:"pinned"`
Setup string `json:"setup"` // guided, manifest
// Note adds a detail under the description, e.g. GitHub-backed inGitDB.
Note string `json:"note,omitempty"`
// ManifestSteps are the steps for a manifest-only engine, in order; the
// last one points to the documentation.
ManifestSteps []envelope.Next `json:"manifest_steps,omitempty"`
}
Engine is one storage choice in the catalogue.
func Engines ¶ added in v0.11.0
func Engines() []Engine
Engines is the storage catalogue in display order: inGitDB and SQLite pinned, then the rest by name (database-setup-and-providers#REQ:catalogue-order-and-filter). This order does not change the backend build order.
func FilterEngines ¶ added in v0.11.0
FilterEngines keeps the engines whose id, name or description contains filter, ignoring case, in their order (REQ:catalogue-order-and-filter). The web console applies the same rule in web/src/engines.ts.
func FindEngine ¶ added in v0.11.0
FindEngine returns the catalogue entry for id.
type EnginesDocument ¶ added in v0.11.0
type EnginesDocument struct {
Schema int `json:"schema"`
Engines []Engine `json:"engines"`
Next []envelope.Next `json:"next"`
}
EnginesDocument is the body of GET /api/local/v1/engines and the --json output of `ovdb engines`.
func NewEnginesDocument ¶ added in v0.11.0
func NewEnginesDocument() EnginesDocument
NewEnginesDocument wraps the catalogue.
type HomeDocument ¶ added in v0.9.0
type HomeDocument struct {
Schema int `json:"schema"`
StatusLine []CopyRef `json:"status_line"`
QuestionKey string `json:"question_key"`
Options []HomeOption `json:"options"`
}
HomeDocument is the body of GET /api/local/v1/home: the status line and the implemented Home options in the founder's order (first-run-onboarding#REQ:home-menu-options, REQ:home-status-line). The TUI and the web console both render it, so neither builds the menu.
func NewHome ¶ added in v0.9.0
func NewHome(server Server, databases []Database, context *dbcontext.Context) HomeDocument
NewHome builds Home for server, the registered databases and the context that applies to the caller (nil when none does). Options appear here only once they are implemented; later increments insert theirs in the founder's order.
A returning user (at least one database) sees one summary line above the same question and menu: `2 databases · using todo (this project) · OVDB server running at …` (first-run-onboarding#REQ:returning-user-home).
type HomeOption ¶ added in v0.9.0
type HomeOption struct {
ID string `json:"id"`
Group string `json:"group"` // primary, secondary
LabelKey string `json:"label_key"`
WebLabelKey string `json:"web_label_key,omitempty"`
DescriptionKey string `json:"description_key,omitempty"`
Badge *Badge `json:"badge,omitempty"`
// Disabled options are shown with DescriptionKey saying why.
Disabled bool `json:"disabled,omitempty"`
}
HomeOption is one Home menu option. LabelKey is the terminal wording; WebLabelKey, when set, replaces it in the web console, which cannot start the server that serves it (parity E1).
type MountRecord ¶ added in v0.11.0
type MountRecord struct {
ID string `json:"id"`
Manifest string `json:"manifest"`
State string `json:"state"`
Reason string `json:"reason,omitempty"`
}
MountRecord is one database's entry in mounts.json.
type Mounter ¶ added in v0.11.0
type Mounter interface {
Mount(db *core.Database) error
UnmountContext(ctx context.Context, id string) error
}
Mounter is the part of the openvaultdb-go server the registry drives.
type Mounts ¶ added in v0.11.0
type Mounts struct {
Schema int `json:"schema"`
Databases []MountRecord `json:"databases"`
}
Mounts is mounts.json: what the running server mounted and what needs attention, with reasons already redacted.
func ReadMounts ¶ added in v0.11.0
ReadMounts reads mounts.json; nil when there is none.
type Registration ¶ added in v0.11.0
type Registration struct {
ID string
Manifest string
Parsed *manifest.Manifest // nil when the file cannot be parsed
Err error // why it cannot be parsed
}
Registration is one manifest file in the registry, read without mounting.
func ReadRegistry ¶ added in v0.11.0
func ReadRegistry(home string) ([]Registration, error)
ReadRegistry lists the manifests in <home>/databases, sorted by file name. A manifest that cannot be read or parsed is still listed, under its file name, with its error: one broken file never hides the others (local-server-and-web-console#REQ:registry-serving).
func (Registration) Describe ¶ added in v0.11.0
func (r Registration) Describe() Database
Describe is registration as listed, with state and reason left to the caller.
type Registry ¶ added in v0.11.0
type Registry struct {
// contains filtered or unexported fields
}
Registry is the running server's view of <home>/databases: it mounts every manifest, keeps each one's mount state, and creates, reloads and removes registrations while serving. Only the server holding home.lock owns one (local-server-and-web-console#REQ:single-server-home-lock).
Database ids are unique ignoring case (registry files live on file systems that may ignore case); commands name a database by its exact id, or by any casing when exactly one registered id matches.
func OpenRegistry ¶ added in v0.11.0
func OpenRegistry(dirs paths.Dirs, srv Mounter, logf func(format string, args ...any), opts RegistryOptions) (*Registry, error)
OpenRegistry reads <home>/databases and records every registration as mounting, without mounting anything: call MountAll once the server listens. It never blocks on storage.
func (*Registry) AwaitMount ¶ added in v0.12.0
AwaitMount waits while database id is still mounting after a start or reload, up to its mount deadline, so a data request that arrives right after a command auto-started the server finds the database served rather than not found (database-context-navigation#REQ:data-commands-use-server). It returns at once for a database in any other state, or none.
func (*Registry) Close ¶ added in v0.11.0
func (r *Registry) Close()
Close unmounts every database, releasing engine resources such as SQLite file handles, and removes mounts.json: without a server, mount state is unknown. Mounts still in flight are closed when they finish.
func (*Registry) Connect ¶ added in v0.14.0
func (r *Registry) Connect(request ConnectRequest) (DatabaseResult, error)
Connect registers existing storage and serves it without a restart. It never writes into the storage: the manifest lives in <home>/databases, the inferred-schema catalogue in <home>/catalogues, Git configuration is left alone, and a SQLite file is described from its own tables so mounting creates none. The storage is mounted once to validate it, and nothing is kept unless that succeeds.
func (*Registry) Create ¶ added in v0.11.0
func (r *Registry) Create(request CreateRequest) (DatabaseResult, error)
Create registers, creates and mounts a new database without a restart. It never overwrites: a registered id is already_exists and a location in use is location_not_empty, both with nothing changed (database-setup-and-providers#REQ:create-never-overwrites).
func (*Registry) GitStorage ¶ added in v0.14.0
GitStorage is the local inGitDB folder database id keeps its data in.
func (*Registry) MountAll ¶ added in v0.11.0
MountAll mounts every registration still mounting, each with its own deadline and in parallel, and returns when all are settled or ctx ends (a server stopping while storage is unreachable). A database that fails, times out or whose storage is missing needs attention, with a redacted reason in status, mounts.json and server.log (local-server-and-web-console#REQ:registry-serving).
func (*Registry) Reconnect ¶ added in v0.12.0
func (r *Registry) Reconnect(request CreateRequest) (DatabaseResult, error)
Reconnect registers and serves an existing inGitDB folder without touching its files: a database OVDB created and a person later removed from OVDB (its data kept), such as the TODO demo installed again into its own folder. Connecting any other storage is `ovdb databases connect`.
func (*Registry) Reload ¶ added in v0.11.0
Reload mounts database id again from its manifest, so an edited manifest (a SQLite schema, a fixed connection variable) or restored storage takes effect without restarting the server.
func (*Registry) ReloadAll ¶ added in v0.11.0
func (r *Registry) ReloadAll(ctx context.Context) (DatabasesDocument, error)
ReloadAll reloads every registration, picks up manifests added to <home>/databases by hand and forgets ones deleted by hand.
func (*Registry) Remove ¶ added in v0.11.0
Remove unregisters database id without deleting its data, and says where the data remains (database-setup-and-providers#REQ:list-and-remove). The manifest goes first, so a failure leaves the database registered and served; the drain of in-flight requests happens without the registry lock, so status and lists never wait on it.
type RegistryOptions ¶ added in v0.11.0
type RegistryOptions struct {
MountTimeout time.Duration
// Getenv reads the server's environment; os.Getenv when nil.
Getenv func(string) string
}
RegistryOptions tune a registry; the zero value is the default.
type Server ¶
type Server struct {
State string `json:"state"`
Address string `json:"address"`
FallbackAddress string `json:"fallback_address"`
Port int `json:"port"`
Version string `json:"version,omitempty"`
PID int `json:"pid,omitempty"`
StartedAt *time.Time `json:"started_at,omitempty"`
Log string `json:"log"`
}
Server describes the local OVDB server in status and server documents. It carries no uptime: a start time keeps two reads of the same server byte-identical, and presentations format the uptime from it.
func RunningServer ¶
RunningServer describes the server recorded in record.
type ServerConfig ¶
type ServerConfig struct {
Port int `yaml:"port,omitempty" json:"port,omitempty"`
CORS []string `yaml:"cors,omitempty" json:"cors,omitempty"`
ReadOnly bool `yaml:"read_only,omitempty" json:"read_only,omitempty"`
}
ServerConfig is the server section of config.yaml.
type ServerDocument ¶
type ServerDocument struct {
Schema int `json:"schema"`
Server Server `json:"server"`
Next []envelope.Next `json:"next"`
}
ServerDocument is the body of GET /api/local/v1/server and the --json output of `ovdb server start|stop|restart|status`. Next holds the commands that change the server's state, so every presentation shows the same ones (the web console cannot run them itself: parity E1 and E2).
func NewServerDocument ¶
func NewServerDocument(server Server) ServerDocument
NewServerDocument wraps server in its document.
type Status ¶
type Status struct {
Schema int `json:"schema"`
Version string `json:"version"`
Locations paths.Dirs `json:"locations"`
Server Server `json:"server"`
Databases []Database `json:"databases"`
// Context is the database and path that apply where the client runs
// (capability 14); null when none does.
Context *dbcontext.Context `json:"context"`
// Demo says whether the TODO demo is installed, and where.
Demo DemoStatus `json:"demo"`
// Skills lists each OVDB skill and the AI agents it is installed for,
// as whoever built the document resolves their directories.
Skills []skills.Installed `json:"skills"`
// Telemetry is the usage statistics state, and why nothing is sent, as
// the process that built the document evaluates it
// (first-run-onboarding#REQ:status-command, telemetry-consent
// #REQ:sender-process-decides).
Telemetry StatusTelemetry `json:"telemetry"`
Next []envelope.Next `json:"next"`
}
Status is the body of GET /api/local/v1/status and of `ovdb status --json` (first-run-onboarding#REQ:status-command). Later increments add databases, context, demo, skills and telemetry as they are implemented.
func NewStatus ¶
func NewStatus(version string, dirs paths.Dirs, server Server, databases []Database, context *dbcontext.Context, installed []skills.Installed) Status
NewStatus builds the status for this ovdb version, locations, server, registered databases and installed skills. next is the bootstrap list an agent without a skill relays (ai-agent-skills#REQ:agent-bootstrap-without-skill): terminal, web and command setup, then the demo and the storage skill while they are not installed.
func (*Status) SetSkills ¶ added in v0.17.0
SetSkills replaces the skills field group and the next entries that depend on it. A client calls it with the skills it resolved itself, so `ovdb status` agrees with `ovdb skills list` whichever shell started the server (local-server-and-web-console#REQ:client-values-and-mismatch).
type StatusTelemetry ¶ added in v0.18.0
type StatusTelemetry struct {
State string `json:"state"`
Sending bool `json:"sending"`
Reason string `json:"reason,omitempty"`
ReasonText string `json:"reason_text,omitempty"`
}
StatusTelemetry is the status document's telemetry group.
type TelemetryOutcome ¶ added in v0.18.0
type TelemetryOutcome struct {
Consent telemetry.Consent
Changed bool // false when the state already matched
// Backup is where an unreadable config.yaml was saved before a disable
// rewrote it.
Backup string
}
TelemetryOutcome is a recorded telemetry decision.
func ChangeTelemetry ¶ added in v0.18.0
func ChangeTelemetry(dirs paths.Dirs, change telemetry.Change, channel telemetry.Channel, now time.Time) (TelemetryOutcome, error)
ChangeTelemetry records a person's telemetry decision in config.yaml (telemetry-consent#REQ:opt-in-state): enabling needs ConfirmedByUser and creates the install id; disabling always works and removes it. channel is the deciding interface. The caller must be the home's single writer, as for ApplyConfigChange.
Disabling never fails on an unreadable config.yaml (review F7): the file is copied, byte for byte, next to itself first; then only its telemetry key is replaced when it is still a YAML mapping, or it is rewritten with just the disabled state when it is not YAML at all.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package dbcontext is the one resolver for "which database and path does this command act on" (decision 0008, spec/features/database-context-navigation REQ:use-sets-scoped-context and REQ:context-lookup).
|
Package dbcontext is the one resolver for "which database and path does this command act on" (decision 0008, spec/features/database-context-navigation REQ:use-sets-scoped-context and REQ:context-lookup). |
|
Package demo is the built-in TODO demo service (spec/features/todo-demo, decision 0010): two lists, To buy and To watch, in a schemaless inGitDB database registered as `todo` at <data home>/demos/todo, and the documents `ovdb demo install|open|status`, the TUI, the web console and the TODO app render.
|
Package demo is the built-in TODO demo service (spec/features/todo-demo, decision 0010): two lists, To buy and To watch, in a schemaless inGitDB database registered as `todo` at <data home>/demos/todo, and the documents `ovdb demo install|open|status`, the TUI, the web console and the TODO app render. |
|
Package explore is Explore data (spec/features/explore-data-handoff): the intent-first menu that hands database access to DataTug CLI or names DataTug.app's honest limitation, never running DataTug itself.
|
Package explore is Explore data (spec/features/explore-data-handoff): the intent-first menu that hands database access to DataTug CLI or names DataTug.app's honest limitation, never running DataTug itself. |
|
Package skills is the AI agent skills service (spec/features/ai-agent-skills, capabilities 20 and 21): the two Agent Skills embedded from skills/, where each AI agent (harness) keeps them, and installing one skill with github.com/strongo/cli-helpers/skillsync.
|
Package skills is the AI agent skills service (spec/features/ai-agent-skills, capabilities 20 and 21): the two Agent Skills embedded from skills/, where each AI agent (harness) keeps them, and installing one skill with github.com/strongo/cli-helpers/skillsync. |
|
skillstest
Package skillstest is the test support of the packages that show or install AI agent skills: what an interrupted install leaves behind.
|
Package skillstest is the test support of the packages that show or install AI agent skills: what an interrupted install leaves behind. |