Documentation
¶
Overview ¶
Package wasmengine composes the services the browser engine serves (agni issue 178). It is separate from cmd/agni-wasm, which only bridges it to JavaScript, so the composition builds and is tested natively, against the server's, without a browser.
Index ¶
Constants ¶
const BrowserMount = "local"
BrowserMount is the mount a page puts dropped files in (agni issue 854). Its files exist only in the visitor's browser, and a `.zip` in it reads as the folder it was made from.
const Namespace = "agni"
Namespace is the global the wasm build's exports live under, globalThis.agni.
Variables ¶
This section is empty.
Functions ¶
func Build ¶
Build composes the engine over root, whose top-level directories are the mounts, which is how goapplib's wasmhost holds them, with nothing kept past the worker.
func BuildWith ¶
BuildWith is Build with options, the rebuild function cmd/agni-wasm hands the host.
func StoreVersion ¶
func StoreVersion() string
StoreVersion names this build for the persistent tier: the commit, the uncommitted changes when there are any, and the layout of what is stored. It is empty, which persists nothing, for a build that cannot say what it was built from, since one could read a file differently from another and share a name with it.
func WithheldPlaceholder ¶ added in v0.3.0
WithheldPlaceholder is the placeholder for a held-back file whose content hash is sha256, as ListDesignFiles spells it.
Types ¶
type Engine ¶
type Engine struct {
// Handler serves the Connect API, as `agni serve` does at the same paths.
Handler http.Handler
// Paths are the service paths Handler answers.
Paths []string
// Warnings are the legitimate absences agni.New reports, such as no datasheet corpus.
Warnings []string
// Cache is the design cache every service reads through, for its counters.
Cache *service.DesignCache
}
Engine is one composition over one mount table. The browser rebuilds it when a mount changes, which is cheaper to reason about than services caching a project tree that moved under them.
type Options ¶
type Options struct {
// Store keeps every parsed design, drawing and board past the worker, so another worker over the
// same files (a reload, a second lane, a lane's replacement) restores them rather than reading
// them again (agni issue 911). In the browser it is wasmhost.BrowserCache. Nil keeps nothing.
Store service.BlobStore
// Version names the engine that wrote what Store holds. Empty means StoreVersion().
Version string
// CollectBetweenRequests is set by a caller that has turned the Go collector's automatic cycles
// off (debug.SetGCPercent(-1)), as cmd/agni-wasm does. The engine then collects after a request
// when the heap has doubled since its last collection, and likewise as each file opens, as well as
// after each layer it loads, so never in the middle of evaluating (agni issue 1010). A native caller leaves it off, since its collector
// runs concurrently on other cores and is cheap there.
CollectBetweenRequests bool
}
Options configures an engine beyond its mount table.