graphrender

package
v0.1.0-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: Apache-2.0 Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

Examples

Constants

This section is empty.

Variables

View Source
var ErrUnsupportedFormat = specrender.ErrUnsupportedFormat

ErrUnsupportedFormat reports a goav:graph URI naming a format other than text, dot, or mermaid.

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

func RenderURI(spec pipeline.Spec, target string) (string, error)

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.

Jump to

Keyboard shortcuts

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