Documentation
¶
Overview ¶
Package graphrender renders a pipeline.Spec — the graph Runtime.Describe plans and Task.Spec reports once built — as human-readable text, Graphviz DOT, or Mermaid, and annotates goav.TaskSnapshot and goav.BranchSnapshot views with branch and tap labels. It is diagnostics outside the goav core: the root package never imports it, so any graph a recipe or expert builder describes can be rendered.
The format is selected by a goav:graph URI:
out, err := graphrender.RenderURI(spec, "goav:graph") // text out, err := graphrender.RenderURI(spec, "goav://graph/dot") // DOT out, err := graphrender.RenderURI(spec, "goav://graph?format=mermaid") flow, err := graphrender.RenderTaskFlowchart(task) // live task flow, err := graphrender.RenderSnapshotFlowchart(task.Snapshot()) flow, err := graphrender.RenderBranchFlowchart(attachment.Snapshot())
Index ¶
- Variables
- func RenderBranchFlowchart(branch goav.BranchSnapshot) (string, error)
- func RenderBranchURI(branch goav.BranchSnapshot, target string) (string, error)
- func RenderSnapshotFlowchart(snap goav.TaskSnapshot) (string, error)
- func RenderSnapshotURI(snap goav.TaskSnapshot, target string) (string, error)
- func RenderTaskFlowchart(task interface{ ... }) (string, error)
- func RenderTaskURI(task interface{ ... }, target string) (string, error)
- func RenderURI(spec pipeline.Spec, target string) (string, error)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ErrUnsupportedFormat = specrender.ErrUnsupportedFormat
ErrUnsupportedFormat reports a goav:graph URI naming a format other than text, dot, or mermaid.
var ErrUnsupportedURI = specrender.ErrUnsupportedURI
ErrUnsupportedURI reports a render target that is not a goav:graph URI.
Functions ¶
func RenderBranchFlowchart ¶
func RenderBranchFlowchart(branch goav.BranchSnapshot) (string, error)
RenderBranchFlowchart renders an attachment/branch snapshot as a Mermaid flowchart. The branch's nodes are annotated with the branch name and lifecycle state.
Example ¶
package main
import (
"fmt"
"strings"
"github.com/thesyncim/goav"
"github.com/thesyncim/goav/graphrender"
"github.com/thesyncim/goav/pipeline"
)
func main() {
branch := goav.BranchSnapshot{
Name: "preview",
State: goav.BranchAttached,
Spec: pipeline.Spec{
Nodes: []pipeline.NodeSpec{
{Name: "preview-copy", Kind: pipeline.NodeStage, Detail: "copy"},
{Name: "preview-sink", Kind: pipeline.NodeSink},
},
Edges: []pipeline.EdgeSpec{{From: "preview-copy", To: "preview-sink"}},
},
}
flowchart, err := graphrender.RenderBranchFlowchart(branch)
fmt.Println("err:", err)
fmt.Println(strings.HasPrefix(flowchart, "flowchart LR"))
fmt.Println(strings.Contains(flowchart, "branch=preview (attached)"))
}
Output: err: <nil> true true
func RenderBranchURI ¶
func RenderBranchURI(branch goav.BranchSnapshot, target string) (string, error)
RenderBranchURI renders an attachment/branch snapshot in the format selected by target.
func RenderSnapshotFlowchart ¶
func RenderSnapshotFlowchart(snap goav.TaskSnapshot) (string, error)
RenderSnapshotFlowchart renders a task snapshot as a Mermaid flowchart. Runtime branch-owned nodes are annotated with branch names and lifecycle state, so callers can render a running task after capturing Snapshot().
Example ¶
package main
import (
"fmt"
"strings"
"github.com/thesyncim/goav"
"github.com/thesyncim/goav/graphrender"
"github.com/thesyncim/goav/pipeline"
)
func main() {
snap := goav.TaskSnapshot{
Spec: pipeline.Spec{
Name: "live",
Nodes: []pipeline.NodeSpec{
{Name: "source", Kind: pipeline.NodeSource},
{Name: "meter", Kind: pipeline.NodeStage, Detail: "rms"},
{Name: "archive", Kind: pipeline.NodeSink},
},
Edges: []pipeline.EdgeSpec{
{From: "source", To: "meter"},
{From: "meter", To: "archive"},
},
},
Branches: []goav.BranchSnapshot{{
Name: "recording",
State: goav.BranchAttached,
Nodes: []pipeline.NodeRef{"meter", "archive"},
}},
}
flowchart, err := graphrender.RenderSnapshotFlowchart(snap)
fmt.Println("err:", err)
fmt.Println(strings.HasPrefix(flowchart, "flowchart LR"))
fmt.Println(strings.Contains(flowchart, "branch=recording (attached)"))
}
Output: err: <nil> true true
func RenderSnapshotURI ¶
func RenderSnapshotURI(snap goav.TaskSnapshot, target string) (string, error)
RenderSnapshotURI renders a task snapshot in the format selected by target. It is useful when a host wants to persist, diff, or render a point-in-time task view without keeping a task handle in scope.
func RenderTaskFlowchart ¶
func RenderTaskFlowchart(task interface{ Snapshot() goav.TaskSnapshot }) (string, error)
branch names and lifecycle state.
func RenderTaskURI ¶
func RenderTaskURI(task interface{ Snapshot() goav.TaskSnapshot }, target string) (string, error)
RenderTaskURI renders the current snapshot of a running task-like value in the format selected by target. The task only needs to expose Snapshot, so this package stays outside the core import graph.
func RenderURI ¶
RenderURI renders spec in the format the goav:graph target URI selects: "goav:graph" (or an empty target) renders text, "goav://graph/dot" and "goav://graph/mermaid" select by path, and a format query parameter ("goav://graph?format=dot") wins over the path. Unknown formats return ErrUnsupportedFormat; non-goav:graph targets return ErrUnsupportedURI.
Types ¶
This section is empty.