Documentation
¶
Overview ¶
Package visualize draws the dependency graph of a container.
The container describes its graph with the model below and hands it to a Renderer, which decides what the drawing looks like: Graphviz DOT, a text tree for the terminal, an HTML page, or anything else implementing the interface.
c.Visualize(os.Stdout, visualize.WithRenderer(visualize.ASCII{}))
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultOptions ¶
func DefaultOptions(fallback Renderer) *options
DefaultOptions returns the options a drawing starts from, fallback being the renderer used when none is given.
Types ¶
type ASCII ¶
type ASCII struct {
// Color draws highlighted items in red and dashed ones dimmed, using ANSI escape
// codes. Leave it off when the output does not go to a terminal.
Color bool
}
ASCII renders graphs as plain text trees for the terminal, one per cluster, listing under every node the nodes it points to:
root
|-- main.Database (singleton, resolved)
`-- main.Shape (transient)
`-> main.Database
scope "request"
`-- main.Logger (singleton)
`-> main.Database [root]
A target outside the cluster of its node is followed by the label of its own cluster. A highlighted node or edge is marked with (!) and drawn as =>, a dashed one is left as its label describes it.
func (ASCII) ContentType ¶
type DOT ¶
type DOT struct{}
DOT renders graphs in the Graphviz DOT language:
dot -Tsvg container.dot -o container.svg
func (DOT) ContentType ¶
type Graph ¶
type Graph struct {
Name string
Clusters []Cluster
Nodes []Node // nodes outside of any cluster
Edges []Edge
}
Graph is a directed graph ready to be rendered.
type HTML ¶
type HTML struct {
// Title is the title of the page, "Dependency graph" when empty.
Title string
}
HTML renders graphs as a standalone web page. The page lays the DOT drawing of the graph out in the browser with Viz.js, loaded from a CDN, and falls back to the ASCII drawing when scripts do not run.
http.Handle("/debug/container", c.VisualizeHandler())
func (HTML) ContentType ¶
type Node ¶
Node is a single box, identified by a number unique within the Graph. The first line of its label names it, the others describe it.
type Option ¶
type Option func(*options)
Option is a functional option for configuring a drawing.
func WithRenderer ¶
WithRenderer sets the renderer drawing the graph.