Documentation
¶
Index ¶
- func GetNodeNames(nodes []*Node) []string
- type Builder
- type ComponentBatches
- type DockerClient
- type Graph
- func (g *Graph) GetConnectedComponents() ([]*ComponentBatches, error)
- func (g *Graph) GetConnectedComponentsForShutdown() ([]*ComponentBatches, error)
- func (g *Graph) GetLeafNodes() []*Node
- func (g *Graph) GetNode(name string) (*Node, bool)
- func (g *Graph) GetRootNodes() []*Node
- func (g *Graph) GetShutdownBatches() ([][]*Node, error)
- func (g *Graph) GetStartupBatches() ([][]*Node, error)
- func (g *Graph) HasCycles() (bool, []string)
- func (g *Graph) TopologicalSort() (*SortedContainers, error)
- func (g *Graph) Validate() error
- type Node
- type SortedContainers
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetNodeNames ¶
GetNodeNames extracts container names from a list of nodes
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder constructs dependency graphs from container information
func NewBuilder ¶
func NewBuilder(dockerClient DockerClient, logger *logger.Logger) *Builder
NewBuilder creates a new graph builder
type ComponentBatches ¶
type ComponentBatches struct {
Batches [][]*Node // Batches of nodes that can run in parallel within this component
}
ComponentBatches represents a single connected component with its batches
type DockerClient ¶
type DockerClient interface {
GetContainer(ctx context.Context, containerID string) (*client.ContainerInspectResult, error)
}
DockerClient interface for container operations needed by the builder
type Graph ¶
Graph represents the complete dependency graph of containers
func (*Graph) GetConnectedComponents ¶
func (g *Graph) GetConnectedComponents() ([]*ComponentBatches, error)
GetConnectedComponents identifies independent subgraphs in the dependency graph. Each component is a set of containers that are connected through dependencies (directly or indirectly). Containers in different components have no dependency relationships with each other and can be processed in parallel.
Returns a slice of components, where each component contains batches of nodes. Nodes within the same batch have no dependencies on each other and can run in parallel.
func (*Graph) GetConnectedComponentsForShutdown ¶
func (g *Graph) GetConnectedComponentsForShutdown() ([]*ComponentBatches, error)
GetConnectedComponentsForShutdown returns components ordered for shutdown (same components but batches are reversed)
func (*Graph) GetLeafNodes ¶
GetLeafNodes returns all nodes with no children
func (*Graph) GetRootNodes ¶
GetRootNodes returns all nodes with no parent dependencies
func (*Graph) GetShutdownBatches ¶
GetShutdownBatches groups containers into batches for parallel shutdown This is the reverse of startup batches
func (*Graph) GetStartupBatches ¶
GetStartupBatches groups containers into batches that can be started in parallel Containers in the same batch have no dependencies on each other
func (*Graph) TopologicalSort ¶
func (g *Graph) TopologicalSort() (*SortedContainers, error)
TopologicalSort performs a topological sort on the dependency graph Returns containers in startup order (dependencies first)
type Node ¶
type Node struct {
// Container information
ID string
Name string
Labels map[string]string
IsRunning bool
IsPlaceholder bool // True if container doesn't exist but is referenced as a dependency
// Dependency information
Parents []*Node // Containers this one depends on (must start first)
Children []*Node // Containers that depend on this one (start after)
// Startup configuration from labels
StartupDelay int // Delay in seconds after dependencies are ready
WaitForHealthcheck bool // Wait for health check to pass
// Container configuration
StopTimeout *int // Container's configured stop timeout in seconds (nil = Docker default of 10s)
// contains filtered or unexported fields
}
Node represents a container in the dependency graph
func FilterByNames ¶
FilterByNames returns nodes filtered by a list of names to exclude
func FilterByState ¶
FilterByState returns nodes filtered by running state
func NewPlaceholderNode ¶
NewPlaceholderNode creates a placeholder node for a missing dependency
func (*Node) HasChildren ¶
HasChildren returns true if the node has any child dependencies
func (*Node) HasParents ¶
HasParents returns true if the node has any parent dependencies
type SortedContainers ¶
type SortedContainers struct {
StartupOrder []*Node // Order for starting containers
ShutdownOrder []*Node // Order for stopping containers (reverse of startup)
}
SortedContainers represents the result of topological sort