graph

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package graph runs a function over a dependency DAG with bounded concurrency.

Independent branches run in parallel; a node runs only after all of its dependencies have succeeded. If a dependency fails (or is skipped), the node is skipped too, but independent branches keep going — fail-fast per branch, not globally. The caller inspects the returned per-node results.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Reverse

func Reverse(deps map[string][]string) map[string][]string

Reverse flips edge direction: if a depends on b in deps, then in the result b depends on a. Used to uninstall in reverse dependency order.

func Run

func Run(ctx context.Context, deps map[string][]string, concurrency int, fn func(context.Context, string) error) map[string]Result

Run executes fn for every node, where deps[node] lists the nodes that must succeed before it. concurrency bounds how many fn calls run at once (<=0 means no limit). The dependency graph must be acyclic (validated upstream); a cycle would deadlock. Run returns a result per node and never returns early.

Types

type Result

type Result struct {
	// Err is nil on success. On failure it is the node function's error; on a
	// skip it explains which dependency caused it. Skipped is true only for the
	// latter.
	Err     error
	Skipped bool
}

Result is the outcome for a single node.

Jump to

Keyboard shortcuts

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