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

netgraph

package
v1.3.104 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package netgraph lays out the transport graph and serves it as a canvas page.

Index

Constants

View Source
const RefreshEvery = 15 * time.Minute

RefreshEvery is how long a layout is served before it is recomputed.

Variables

This section is empty.

Functions

func EngineLoader

func EngineLoader(w http.ResponseWriter, r *http.Request)

EngineLoader serves the netview module's wasm_exec.js.

func EngineWasm

func EngineWasm(w http.ResponseWriter, r *http.Request)

EngineWasm serves the netview module.

Types

type Edge

type Edge struct {
	A, B uint16
	Mask uint8
}

Edge joins Nodes[A] and Nodes[B]. Mask has bit i set for Types[i].

type Graph

type Graph struct {
	Nodes []string
	X, Y  []float64
	// Degree is how many transports each visor has.
	Degree []int
	Types  []string
	Edges  []Edge
	// Transports is how many transports the graph was built from.
	Transports int
	// Group numbers each visor's group from 0, or is -1 for one alone.
	// Nil when no groups were given. Groups is how many there are.
	Group  []int
	Groups int
}

Graph is a laid out transport graph. Every pair of visors joined by at least one transport is one edge, with a bit set for each type joining them.

func Build

func Build(links []Link, prev map[string][2]float64, groups map[string]string) *Graph

Build turns links into a graph laid out from prev, the positions of an earlier layout by key, so that a refreshed picture stays where it was. Visors that groups gives one key, when two or more are in the graph, are numbered as a group and laid out together.

func (*Graph) Positions

func (g *Graph) Positions() map[string][2]float64

Positions returns each visor's place, to lay out the next graph from.

type Link struct {
	A, B string
	Type string
}

Link is one transport between two visors, by their keys in hex.

type Mark

type Mark struct {
	Name  string
	Color string
}

Mark names a color some visors are drawn in.

type Page

type Page struct {
	Title  string
	Back   string
	Source func(ctx context.Context) ([]Link, error)
	// Marks, when set, colors some visors by key, and Legend names the colors.
	Marks  func(ctx context.Context) map[string]string
	Legend []Mark
	// Groups, when set, gives one key to visors that belong together. The
	// page shows group numbers and sizes, never the keys, and GroupsAre says
	// what a group shares, such as "one public IP".
	Groups    func(ctx context.Context) map[string]string
	GroupsAre string
	// contains filtered or unexported fields
}

Page serves the transport graph. Source returns the current transports, or an error while they are not known yet.

func (*Page) ServeHTTP

func (p *Page) ServeHTTP(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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