Documentation
¶
Overview ¶
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.
Installing goes through the registry like any create and seeds the lists through the data API, so the demo's files are exactly what an app writing the same records would produce. It never overwrites: a demo already installed is reported as such, and a conflicting `todo` database or a folder with other files is refused with a --id to use instead.
Index ¶
Constants ¶
const ( // App is the demo name commands default to, leaving room for // `--app <name>` (REQ:demo-command-shape). App = "todo" // DefaultID is the database id the demo installs as. DefaultID = setup.DemoDefaultID // AppPath is the TODO app on the local server (REQ:todo-app-same-origin). AppPath = "/apps/todo/" )
The TODO demo's fixed names.
const ( // ActionOpenApp opens the TODO app signed in. ActionOpenApp = "open_app" // ActionInstall installs the demo. ActionInstall = "install_demo" )
Next actions presentations act on in place (envelope.Next.Action).
const ActionExplore = "explore"
ActionExplore opens Explore data for the demo database (increment 7).
Variables ¶
var Lists = leadingSlash(todo.Lists)
Lists are the demo's list paths, in the order apps show them: todo.Lists (github.com/ingitdb/ingitdb-go/ingitdb/demos/todo), the shared TODO demo records package, with a leading slash.
Functions ¶
Types ¶
type Document ¶
type Document struct {
Schema int `json:"schema"`
App string `json:"app"`
// Installed is true once the demo database is registered.
Installed bool `json:"installed"`
// AlreadyInstalled is set on an install that changed nothing.
AlreadyInstalled bool `json:"already_installed,omitempty"`
// Database is the demo database id; empty until installed.
Database string `json:"database,omitempty"`
// Location is where the demo's files are, or will be once installed.
Location string `json:"location"`
// State is the database's mount state once installed.
State string `json:"state,omitempty"`
// AppPath is the TODO app's path on the local server.
AppPath string `json:"app_path"`
Lists []string `json:"lists"`
Next []envelope.Next `json:"next"`
}
Document is the body of GET /api/local/v1/demo, of POST /api/local/v1/demo/install, and the --json output of `ovdb demo status` and `ovdb demo install`.
type InstallRequest ¶
InstallRequest is the body of POST /api/local/v1/demo/install. Both fields are optional: ID defaults to todo, Path to <data home>/demos/<id> under the data home the client resolved (the server's own when the web console asks).
type Registry ¶
type Registry interface {
Create(request setup.CreateRequest) (setup.DatabaseResult, error)
Reconnect(request setup.CreateRequest) (setup.DatabaseResult, error)
Remove(ctx context.Context, id string) (setup.DatabaseResult, error)
List() ([]setup.Database, error)
}
Registry is the part of setup.Registry installing uses.
type Service ¶
type Service struct {
Dirs paths.Dirs
Registry Registry
Seed Seeder
Now func() time.Time // time.Now when nil
Logf func(format string, args ...any)
// contains filtered or unexported fields
}
Service installs the demo on a running server. Only the server holding home.lock owns one, and every client (CLI, TUI, web console, agents) installs through it, so its mutex serialises every install for the home.
func (*Service) Install ¶
Install registers the demo database, writes the seed lists, records the install, and returns the installed demo (REQ:demo-install-idempotent). An installed demo is reported with AlreadyInstalled and nothing written. Installs run one at a time, so one that finds the demo installed returns only once its lists exist.