live

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

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

View Source
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

View Source
var Opener = openBrowser

Opener opens a URL in the user's browser. Tests replace it.

Functions

func Dir

func Dir() (string, error)

Dir is the directory of the identity file: $VEGALOAD_CONFIG_DIR, or vegaload in the user's config directory.

func Enabled

func Enabled(forceOn, forceOff bool) bool

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

func OpenEnabled(noOpen bool) bool

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.

func Probe

func Probe(ctx context.Context, base *url.URL) error

Probe checks that a live-view service answers at base and accepts projects. It is quick (1.5 s at most) and follows no redirects, so a machine with no service, or no network, loses almost nothing.

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

func Load() (*Identity, error)

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

func Reset() (*Identity, error)

Reset replaces the identity with a new one. Runs of the old project stay where they are, under the old URL.

func (*Identity) BaseURL

func (id *Identity) BaseURL(flag string) (*url.URL, error)

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.

func (*Identity) PageURL

func (id *Identity) PageURL(base *url.URL) string

PageURL is the page that shows the latest run of this machine's project.

func (*Identity) PushURL

func (id *Identity) PushURL(base *url.URL) string

PushURL is where the events of this machine's project are sent.

Jump to

Keyboard shortcuts

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