Help us shape the future of Go! Take the 2026 Go Developer Survey

report

package
v0.4.0 Latest Latest
Warning

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

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

Documentation

Overview

Package report holds the result of a run as a tree — nodes, their hooks and attempts, container lanes — and writes it as JSON, JUnit XML, Markdown or plain text. It is pure data and formatting: the engine builds the tree from its events; this package never imports it.

Everything in a report is already masked by whoever built it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteJSON

func WriteJSON(w io.Writer, r Run) error

WriteJSON writes r as indented JSON. Durations are written as milliseconds (duration_ms, grace_ms).

func WriteJUnit

func WriteJUnit(w io.Writer, r Run) error

WriteJUnit writes r as JUnit XML. Statuses map as: failed → <failure>, error and aborted → <error>, skipped and cancelled → <skipped>. Handled failures pass, with their diagnostics in <system-err>.

func WriteMarkdown

func WriteMarkdown(w io.Writer, r Run) error

WriteMarkdown writes r as a Markdown summary (for digests, PR comments and CI job summaries).

func WriteMermaid

func WriteMermaid(w io.Writer, r Run) error

WriteMermaid writes r as a Mermaid sequence diagram of what actually happened: Flowi and one participant for each host it called, an arrow out and an arrow back for each attempt (with its status and time), and a note for a step that is not a call and failed. It is the living picture of a run, drawn from the report, so it cannot drift from the flow the way a hand-drawn diagram does. Only the host and path of a URL are shown: the query string can hold a credential.

func WriteText

func WriteText(w io.Writer, r Run) error

WriteText writes r as indented plain lines: a header, the node tree, then warnings, notes and the abort reason.

Types

type Abort

type Abort struct {
	Reason   string        `json:"reason"`
	Grace    time.Duration `json:"-"`
	Inflight []string      `json:"inflight"`
}

Abort says why a cancelled run was forced to stop.

func (Abort) MarshalJSON

func (a Abort) MarshalJSON() ([]byte, error)

MarshalJSON adds grace_ms.

type Attempt

type Attempt struct {
	N        int           `json:"n"`
	Method   string        `json:"method"`
	URL      string        `json:"url"`
	Status   int           `json:"status,omitempty"`
	Error    string        `json:"error,omitempty"`
	Duration time.Duration `json:"-"`
}

Attempt is one HTTP attempt of a request.

func (Attempt) MarshalJSON

func (a Attempt) MarshalJSON() ([]byte, error)

MarshalJSON adds duration_ms.

type Diagnostic

type Diagnostic struct {
	Code     string `json:"code"`
	Severity string `json:"severity,omitempty"`
	Message  string `json:"message"`
	File     string `json:"file,omitempty"`
	Line     int    `json:"line,omitempty"`
	Column   int    `json:"column,omitempty"`
}

Diagnostic is a diagnostic with its message already rendered.

type Hook

type Hook struct {
	Phase       string        `json:"phase"`
	Level       string        `json:"level"`
	Step        string        `json:"step"`
	Index       int           `json:"index"`
	Status      string        `json:"status"`
	Duration    time.Duration `json:"-"`
	Diagnostics []Diagnostic  `json:"diagnostics,omitempty"`
	Nodes       []Node        `json:"nodes,omitempty"`
}

Hook is one API hook step of a request node.

func (Hook) MarshalJSON

func (h Hook) MarshalJSON() ([]byte, error)

MarshalJSON adds duration_ms.

type Lane

type Lane struct {
	Label string `json:"label"`
	Nodes []Node `json:"nodes"`
}

Lane is one group of a container's children.

type Node

type Node struct {
	Path        string         `json:"path"`
	ID          string         `json:"id"`
	Type        string         `json:"type"`
	Name        string         `json:"name,omitempty"`
	Status      string         `json:"status"`
	Handled     bool           `json:"handled,omitempty"` // failed, but on_error let the run continue
	Reason      string         `json:"reason,omitempty"`  // why a skipped node was skipped, when the person chose it
	Started     time.Time      `json:"started,omitzero"`
	Duration    time.Duration  `json:"-"`
	Outputs     map[string]any `json:"outputs,omitempty"`
	Diagnostics []Diagnostic   `json:"diagnostics,omitempty"`
	Attempts    []Attempt      `json:"attempts,omitempty"`
	Hooks       []Hook         `json:"hooks,omitempty"`
	Lanes       []Lane         `json:"lanes,omitempty"`
}

Node is one node instance. Containers group their children in Lanes (batch iterations, parallel branches, the chosen condition branch).

func (Node) MarshalJSON

func (n Node) MarshalJSON() ([]byte, error)

MarshalJSON adds duration_ms.

type Note

type Note struct {
	Path string `json:"path"`
	Text string `json:"text"`
}

Note is the text of a note node.

type OutputValue

type OutputValue struct {
	Name  string `json:"name"`
	Type  string `json:"type,omitempty"`
	Value any    `json:"value"`
}

OutputValue is one declared output of a finished run.

type Run

type Run struct {
	ID         string `json:"id"`
	Kind       string `json:"kind"` // "flow" or "send"
	FlowID     string `json:"flow_id,omitempty"`
	FlowPath   string `json:"flow_path,omitempty"`
	FlowName   string `json:"flow_name,omitempty"`
	Collection string `json:"collection,omitempty"`
	Env        string `json:"env,omitempty"`
	// Overlay is the run-level flowi overlay the run was started with, if any.
	Overlay  string        `json:"overlay,omitempty"`
	Status   string        `json:"status"`
	Seed     uint64        `json:"seed"`
	Started  time.Time     `json:"started,omitzero"`
	Duration time.Duration `json:"-"`
	Nodes    []Node        `json:"nodes"`
	// Vars are the flow's variables when the run ended, masked: what a later
	// partial run needs to carry on from here.
	Vars map[string]any `json:"vars,omitempty"`
	// Outputs are the flow's declared outputs as the run ended, in declared
	// order and masked. One that could not be worked out (the run failed
	// before it had its value) is left out, never filled with a wrong value.
	Outputs  []OutputValue `json:"outputs,omitempty"`
	Warnings []Diagnostic  `json:"warnings,omitempty"`
	Notes    []Note        `json:"notes,omitempty"`
	Versions []VersionUse  `json:"versions,omitempty"`
	Aborted  *Abort        `json:"aborted,omitempty"`
}

Run is the report of one run (a flow run or a standalone send).

func (Run) Find

func (r Run) Find(path string) (Node, bool)

Find returns the node with path, searching lanes and hooks.

func (Run) Leaves

func (r Run) Leaves() []Node

Leaves returns every non-container node, depth-first in list order. Nodes inside hooks belong to their request node and are not included.

func (Run) MarshalJSON

func (r Run) MarshalJSON() ([]byte, error)

MarshalJSON adds duration_ms.

type Sequence

type Sequence struct {
	Title string
	Hosts []string // the hosts the run called, in the order it first called them; Flowi is implied
	Steps []SequenceStep
}

Sequence is a run drawn as a sequence diagram, as data: a window can draw it, WriteMermaid writes it as text.

func SequenceOf

func SequenceOf(r Run) Sequence

SequenceOf draws the run: every attempt of every request in the order it happened, loops and hooks included.

type SequenceStep

type SequenceStep struct {
	Kind   string
	Host   int
	Text   string
	Failed bool
}

SequenceStep is one arrow or note. Kind is "call" (Flowi to Host), "reply" (Host back to Flowi) or "note" (Host is -1). Failed marks a refusal, an error or a step that failed.

type VersionUse

type VersionUse struct {
	Path        string `json:"path"`
	RequestID   string `json:"request_id"`
	RequestPath string `json:"request_path"`
	Version     string `json:"version"`
	Source      string `json:"source"`
}

VersionUse records which version of a request a node ran.

Jump to

Keyboard shortcuts

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