dag

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package dag resolves a named dependency graph into levels: each node's distance from having no unmet dependencies, and a flat execution order grouped by ascending level. It's shared by any provider whose jobs declare "run after" dependencies on sibling jobs (CircleCI's workflow `requires:`, GitHub Actions' job `needs:`), so the same algorithm and error handling (unknown dependency, circular dependency, duplicate node) isn't reimplemented per provider.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Levels

func Levels(nodes []Node) (levels map[string]int, order []string, err error)

Levels assigns each node the length of its longest dependency chain (0 for a node with no dependencies), so nodes at the same level can run one after another while still guaranteeing every dependency's level is lower than its dependents'. It also returns a flat execution order: nodes grouped by ascending level, stable within a level by the order given in nodes.

Types

type Node

type Node struct {
	Name    string
	Depends []string
}

Node is one entry in a dependency graph: a name and the names of other nodes in the same graph it depends on.

Jump to

Keyboard shortcuts

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