orchestrator

package
v0.29.0 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package orchestrator implements a DAG-based service dependency graph for ordered startup of databases, mock servers, and developer applications.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DAG

type DAG struct {
	Nodes map[string]*Node
	// contains filtered or unexported fields
}

DAG is a directed acyclic graph of nodes.

func NewDAG

func NewDAG() *DAG

NewDAG creates an empty DAG.

func (*DAG) AddNode

func (d *DAG) AddNode(n *Node) error

AddNode registers a node.

func (*DAG) Execute

func (d *DAG) Execute(ctx context.Context) (cleanup func(), err error)

Execute starts all nodes in topological order, waiting for health checks between tiers. It returns a cleanup function to stop all started processes.

func (*DAG) TopologicalSort

func (d *DAG) TopologicalSort() ([][]string, error)

TopologicalSort returns execution tiers: each tier contains nodes that can be started in parallel once all nodes in previous tiers are healthy.

func (*DAG) Validate

func (d *DAG) Validate() error

Validate checks for missing dependencies and cycles.

type DependsOnEntry

type DependsOnEntry struct {
	Name      string `yaml:"name"`
	Condition string `yaml:"condition"` // "service_healthy" or "service_started"
}

DependsOnEntry references another node and a readiness condition.

type HealthcheckConfig

type HealthcheckConfig struct {
	// HTTP endpoint to poll (e.g., "http://localhost:8080/health")
	HTTP string `yaml:"http"`
	// TCP address to probe (e.g., "localhost:5432")
	TCP string `yaml:"tcp"`
	// Interval between checks
	Interval time.Duration `yaml:"interval"`
	// Timeout for each check attempt
	Timeout time.Duration `yaml:"timeout"`
	// Number of consecutive successes required
	Retries int `yaml:"retries"`
}

HealthcheckConfig defines how to verify a service is ready.

type Node

type Node struct {
	Name        string
	Type        NodeType
	DependsOn   []string // names of nodes this depends on
	Healthcheck HealthcheckConfig
	Port        int // resolved port (after conflict resolution)
	Runtime     Runtime
	Command     []string
	Env         map[string]string
	Dir         string // Working directory for host process execution (set by include resolver for multirepo)
	// contains filtered or unexported fields
}

Node is a single unit of work in the DAG.

type NodeType

type NodeType int

NodeType categorises a DAG node.

const (
	NodeDatabase NodeType = iota
	NodeMock
	NodeService
)

type Runtime

type Runtime string

Runtime determines where a service executes.

const (
	RuntimeHost       Runtime = "host"
	RuntimeContainer  Runtime = "container"
	RuntimeKubernetes Runtime = "kubernetes"
	RuntimeCloud      Runtime = "cloud"
)

type ServiceConfig

type ServiceConfig struct {
	Name        string            `yaml:"name"`
	Runtime     Runtime           `yaml:"runtime"`
	Command     []string          `yaml:"command"`
	DependsOn   []DependsOnEntry  `yaml:"depends_on"`
	Healthcheck HealthcheckConfig `yaml:"healthcheck"`
	Port        int               `yaml:"port"`
	Env         map[string]string `yaml:"env"`
}

ServiceConfig defines a developer application in devx.yaml.

Jump to

Keyboard shortcuts

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