Documentation
¶
Overview ¶
Package live is the "watch this run in your browser" default of `run`.
With no -stream flag, `run` pushes its events to a live-view service (the rt-bridge app) and opens the page for the run. To make that work with no setup, the first use creates an identity on this machine: a project id, which is what the page URL contains, and a push token. The service creates the project when it first sees the id, so nobody has to visit it first.
The identity is kept in the user's config directory (mode 0600), never in a scenario file, a report, the audit log or any event. The token is sent only as a bearer token to the live-view service. See docs/streaming.md, "Live view".
Index ¶
Constants ¶
const DefaultBase = "http://127.0.0.1:7080"
DefaultBase is the live-view service used when nothing else is configured. For now it is a bridge on this machine; the hosted address replaces it when there is one.
Variables ¶
var Opener = openBrowser
Opener opens a URL in the user's browser. Tests replace it.
Functions ¶
func Dir ¶
Dir is the directory of the identity file: $VEGALOAD_CONFIG_DIR, or vegaload in the user's config directory.
func Enabled ¶
Enabled reports whether `run` should use the live view by default.
-no-live or VEGALOAD_LIVE=off never -live always otherwise unless CI is set
It is the caller's job not to use it by default when the user chose another destination with a -stream flag.
func OpenEnabled ¶
OpenEnabled reports whether the live view page should be opened in the browser.
func OpenEnvAllows ¶
func OpenEnvAllows() bool
OpenEnvAllows reports whether VEGALOAD_OPEN lets VegaLoad open a browser tab at all. VEGALOAD_OPEN=off stops every tab, the HTML report included.
Types ¶
type Identity ¶
type Identity struct {
ProjectID string `json:"projectId"`
PushToken string `json:"pushToken"`
Base string `json:"base,omitempty"` // overrides DefaultBase
CreatedAt time.Time `json:"createdAt"`
Created bool `json:"-"` // made by this call
Path string `json:"-"` // where it is kept
}
Identity is what this machine sends to the live-view service.
func Load ¶
Load returns the identity of this machine, making and saving one when there is none yet (Created is then true). A file that cannot be read or written is an error: an identity that is not kept would make every run a new project.
func Reset ¶
Reset replaces the identity with a new one. Runs of the old project stay where they are, under the old URL.
func (*Identity) BaseURL ¶
BaseURL picks the live-view service: flag, then VEGALOAD_LIVE_URL, then the identity file, then DefaultBase. It returns the URL without a trailing slash, and refuses one with credentials, a query or a fragment.