Documentation
¶
Overview ¶
Package draftview renders what the portal's draft routes report about a source and a draft run of it: the gaps in a validation's lists, why a dry run failed in its author's terms, and the metrics and outputs it reports.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FailureMessage ¶
func FailureMessage(refused *scriptrun.WriteRecord, cause string) string
FailureMessage separates the failures an author acts on differently: a script that is wrong, a script that is right but wanted to write, an upstream that was briefly unavailable, and a run that held too much (#1859).
func IncompleteNote ¶
IncompleteNote states that a validate report's lists are known to be short, which is the one thing an author reading them must not miss.
func Metrics ¶
func Metrics(result *scriptrun.Result) script.RunMetrics
Metrics projects the engine's result into the metrics shape every other run surface reports, so a draft's cost is read in the same units as a platform run's.
func Outputs ¶
func Outputs(outcome *scriptdraft.Outcome) []script.DryRunOutput
Outputs is the shape of what the run would have written. Every entry is a preview by construction, so the locators a persisted output carries are absent rather than empty.
Types ¶
type Response ¶ added in v1.139.0
type Response struct {
RunID string `json:"run_id" example:"run_a1b2c3d4"`
Status string `json:"status" example:"succeeded"`
Error string `json:"error,omitempty"`
// Log is what the run printed, bounded when it was captured.
Log string `json:"log,omitempty"`
LogTruncated bool `json:"log_truncated,omitempty"`
Metrics script.RunMetrics `json:"metrics"`
Outputs []script.DryRunOutput `json:"outputs"`
// State is the object the source would have saved with
// platform.save_state, absent when it saved none (#1537). The draft
// persists it no more than it persists an output.
State map[string]any `json:"state,omitempty"`
// StateCheckpoint is true when State is the run's last
// platform.checkpoint rather than a save_state (#2003).
StateCheckpoint bool `json:"state_checkpoint,omitempty"`
// StateDiscarded is the save_state of a draft that failed, which a
// platform run would discard (#2002); absent otherwise.
StateDiscarded map[string]any `json:"state_discarded,omitempty"`
// Writes lists the persisting platform.call calls the run made, empty
// unless it was run with allow_writes (#1664). Those calls landed, and this
// is the only place the response says so.
Writes []scriptrun.WriteRecord `json:"writes"`
// RefusedWrite is the call the write barrier stopped, absent when it
// stopped none. At most one: the refusal ends the run.
RefusedWrite *scriptrun.WriteRecord `json:"refused_write,omitempty"`
// Message states what did and did not happen, because "succeeded" on a run
// that deliberately wrote nothing is the sentence most likely to be
// misread.
Message string `json:"message"`
// Recording is the run id a test replays this draft's recorded host
// calls by, testing.replay("<recording>"), absent when none was kept
// (#1939).
Recording string `json:"recording,omitempty"`
}
Response is one draft execution as the editor reports it. A failed run answers with the same fields a successful one does: the log is the whole reason to have run it.
func Of ¶ added in v1.139.0
func Of(outcome *scriptdraft.Outcome) Response
Of renders one executed draft.