dependency

package
v0.25.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package dependency provides service dependency graph management for Docker Compose projects.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ServiceDependencyGraph

type ServiceDependencyGraph struct {
	// contains filtered or unexported fields
}

ServiceDependencyGraph models dependencies between services using adjacency maps. Edge direction: dependency -> dependent (i.e., B -> A means A depends on B).

func BuildServiceDependencyGraph

func BuildServiceDependencyGraph(project *types.Project) (*ServiceDependencyGraph, error)

BuildServiceDependencyGraph builds a dependency graph for all services in a project.

func NewServiceDependencyGraph

func NewServiceDependencyGraph() *ServiceDependencyGraph

NewServiceDependencyGraph creates a new, empty dependency graph.

func (*ServiceDependencyGraph) AddDependency

func (sdg *ServiceDependencyGraph) AddDependency(dependent, dependency string) error

AddDependency adds a dependency relationship where `dependent` depends on `dependency`. This creates an edge: dependency -> dependent.

func (*ServiceDependencyGraph) AddService

func (sdg *ServiceDependencyGraph) AddService(serviceName string) error

AddService ensures a service exists in the graph.

func (*ServiceDependencyGraph) CanAddDependency added in v0.24.0

func (sdg *ServiceDependencyGraph) CanAddDependency(dependent, dependency string) (bool, error)

CanAddDependency checks if adding a dependency would create a cycle. Returns true if the dependency can be added without creating a cycle, false otherwise. If false, the dependency would create a cycle.

func (*ServiceDependencyGraph) FindCycle added in v0.25.0

func (sdg *ServiceDependencyGraph) FindCycle() ([]string, error)

FindCycle uses DFS to find a cycle in the dependency graph. Returns the cycle path as a slice of service names, or empty slice if no cycle exists. The returned path starts and ends with the same service to show the complete loop.

func (*ServiceDependencyGraph) GetDependencies

func (sdg *ServiceDependencyGraph) GetDependencies(serviceName string) ([]string, error)

GetDependencies returns the services that the given service depends on.

func (*ServiceDependencyGraph) GetDependents

func (sdg *ServiceDependencyGraph) GetDependents(serviceName string) ([]string, error)

GetDependents returns the services that depend on the given service.

func (*ServiceDependencyGraph) GetTopologicalOrder

func (sdg *ServiceDependencyGraph) GetTopologicalOrder() ([]string, error)

GetTopologicalOrder returns services in topological order (dependencies first). Kahn's algorithm with deterministic tie-breaking (lexical).

func (*ServiceDependencyGraph) GetTransitiveDependencies added in v0.24.0

func (sdg *ServiceDependencyGraph) GetTransitiveDependencies(serviceName string) ([]string, error)

GetTransitiveDependencies returns all transitive dependencies of the given service.

func (*ServiceDependencyGraph) GetTransitiveDependents added in v0.24.0

func (sdg *ServiceDependencyGraph) GetTransitiveDependents(serviceName string) ([]string, error)

GetTransitiveDependents returns all transitive dependents of the given service.

func (*ServiceDependencyGraph) HasCycles

func (sdg *ServiceDependencyGraph) HasCycles() bool

HasCycles checks if the dependency graph contains cycles.

Jump to

Keyboard shortcuts

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