dag

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllDependents added in v0.4.0

func AllDependents(g *Graph, service string) []string

AllDependents returns direct + transitive dependents in topo order (excludes self).

func DirectDependents added in v0.4.0

func DirectDependents(g *Graph, service string) []string

DirectDependents returns the names of services that directly depend on service (i.e. node.Children), in Children order.

func EffectiveState added in v0.2.0

func EffectiveState(node *Node, g *Graph) (docker.ContainerState, []string)

EffectiveState returns the display state for a node, accounting for depends_on conditions. waitingOn lists unsatisfied dependency names when blocked.

func TransitiveDependents added in v0.4.0

func TransitiveDependents(g *Graph, service string) []string

TransitiveDependents returns services that depend on service indirectly (excludes direct dependents and self), in graph topological order.

Types

type DisplayState added in v0.3.0

type DisplayState string

DisplayState is the derived, user-facing state of a service. It folds together raw container state, exit codes, and dependency blocking.

const (
	DisplayHealthy   DisplayState = "healthy"   // running, healthcheck passing or absent
	DisplayStarting  DisplayState = "starting"  // healthcheck in start period
	DisplayBlocked   DisplayState = "blocked"   // waiting on an unsatisfied depends_on
	DisplayPending   DisplayState = "pending"   // no container yet, no unsatisfied deps known
	DisplayCompleted DisplayState = "completed" // exited 0 (init/migration jobs)
	DisplayFailed    DisplayState = "failed"    // exited non-zero
	DisplayUnhealthy DisplayState = "unhealthy" // running but healthcheck failing
	DisplayDegraded  DisplayState = "degraded"  // reserved for Phase 2 (restart loops)
)

The set of derived display states, from fully healthy to terminal failure.

func Display added in v0.3.0

func Display(n *Node, g *Graph) (DisplayState, []string)

Display derives the DisplayState for a node plus the list of unsatisfied dependency names when blocked.

type Graph

type Graph struct {
	Roots   []*Node          // nodes with no dependencies (in-degree 0)
	ByName  map[string]*Node // O(1) service lookup
	Ordered []*Node          // all nodes in topological order (Kahn's)
	Visual  []*Node          // nodes in depth-first render order (matches tree row positions)
}

Graph holds the full dependency graph.

func Build

func Build(cfg *compose.Config) (*Graph, error)

Build constructs the DAG from a parsed compose Config. Returns an error if a circular dependency is detected.

type Node

type Node struct {
	Name          string
	Deps          []string          // all dependency names (sorted, for display)
	DepConditions map[string]string // dep name → condition (e.g. "service_healthy")
	Children      []*Node           // all services that depend on this node (full edge set, used by Kahn's)
	TreeChildren  []*Node           // dependants for which this node is the primary parent (used by renderer)
	State         docker.ContainerState
	Level         int    // render depth: root = 0
	ContainerID   string // Docker container ID (empty when pending / not yet running)

	// Runtime metadata copied from ContainerInfo each poll:
	ExitCode  *int
	Image     string
	Ports     []string
	CreatedAt int64 // unix seconds; 0 when no container exists yet
}

Node represents a single service in the dependency graph.

Jump to

Keyboard shortcuts

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