dag

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2021 License: MIT Imports: 10 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionFunc

type ActionFunc func(GraphObject) error

ActionFunc is a function that is executed for each node in the graph. Returning an error will cause the graph walk to abort.

type GraphObject

type GraphObject interface {
	Name() string   // the unique name for the object
	String() string // the pretty-printed string for the object. Can be one of the following:
	//  - a string of alphabetic ([a-zA-Z\x80-\xff]) characters, underscores ('_').
	//    digits ([0-9]), not beginning with a digit.
	//  - a numeral [-]?(.[0-9]+ | [0-9]+(.[0-9]*)?).
	//  - a double-quoted string ("...") possibly containing escaped quotes (\").
	//  - an HTML string (<...>)
	Dependencies() []string // names of dependencies, in any order
}

GraphObject describes an object that will become a node in the graph

type LogFunc

type LogFunc func(string, ...interface{})

LogFunc is a function that logs a formatted string somewhere

type ObjectGraph

type ObjectGraph struct {
	LogF LogFunc
	// contains filtered or unexported fields
}

ObjectGraph builds and analyzes a graph of the supplied objects

func (*ObjectGraph) Build

func (og *ObjectGraph) Build(objs []GraphObject) error

Build populates the graph with the supplied objects

func (*ObjectGraph) Dot

func (og *ObjectGraph) Dot(name string) ([]byte, error)

Dot returns the GraphWiz DOT output for the graph

func (*ObjectGraph) Info

func (og *ObjectGraph) Info() (root GraphObject, levels [][]GraphObject, err error)

Info returns the root and levels of the graph

func (*ObjectGraph) Walk

func (og *ObjectGraph) Walk(ctx context.Context, af ActionFunc) error

Walk traverses the graph levels in decending order, executing af for every node in a given level concurrently

type WalkError

type WalkError struct {
	// Level is the level of the graph (zero-indexed) where the error occurred
	Level uint
	// Err is the original error
	Err error
}

WalkError defines an error that occurs during a graph Walk()

func (WalkError) Error

func (we WalkError) Error() string

Error satisfies the error interface

Jump to

Keyboard shortcuts

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