orchestrator

package
v0.32.0 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package orchestrator — bridge_node.go implements the DAG executor's handler for RuntimeBridge services. This is the integration glue between the DAG and the internal/bridge/ package. (Idea 46.3)

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 BridgeMode added in v0.32.0

type BridgeMode string

BridgeMode distinguishes between outbound and inbound bridge operations.

const (
	BridgeModeConnect   BridgeMode = "connect"   // Outbound: kubectl port-forward
	BridgeModeIntercept BridgeMode = "intercept" // Inbound: agent + yamux tunnel
)

type BridgeNodeConfig added in v0.32.0

type BridgeNodeConfig struct {
	Kubeconfig    string
	Context       string
	Namespace     string
	TargetService string
	RemotePort    int
	LocalPort     int
	AgentImage    string
	Mode          BridgeMode
	InterceptMode string // "steal" or "mirror"
}

BridgeNodeConfig holds bridge-specific configuration for a DAG node.

type BridgeNodeState added in v0.32.0

type BridgeNodeState struct {
	PortForward *bridge.PortForward  // non-nil for connect mode
	Tunnel      *bridge.Tunnel       // non-nil for intercept mode
	AgentInfo   *bridge.AgentInfo    // non-nil for intercept mode
	SvcState    *bridge.ServiceState // non-nil for intercept mode
	SessionID   string               // set for intercept mode
	Kubeconfig  string               // for cleanup kubectl calls
	Context     string               // for cleanup kubectl calls
	Namespace   string               // for cleanup kubectl calls
}

BridgeNodeState holds the runtime state of a running bridge node, used for teardown.

func (*BridgeNodeState) Cleanup added in v0.32.0

func (s *BridgeNodeState) Cleanup()

Cleanup tears down bridge state in the correct order: 1. Stop tunnel (disconnect Yamux session) 2. Restore service selector (un-redirect traffic) 3. Remove agent pod 4. Stop port-forward subprocess 5. Remove session entry

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) BridgeServicesJSON added in v0.32.0

func (d *DAG) BridgeServicesJSON() ([]byte, error)

BridgeServicesJSON returns a JSON-serializable summary of bridge services for --dry-run.

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) GenerateBridgeEnvVars added in v0.32.0

func (d *DAG) GenerateBridgeEnvVars() map[string]string

GenerateBridgeEnvVars returns the BRIDGE_*_URL env vars for all bridge services in the DAG.

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.

func (*DAG) WriteBridgeEnvFile added in v0.32.0

func (d *DAG) WriteBridgeEnvFile() error

WriteBridgeEnvFile writes the BRIDGE_*_URL env vars to ~/.devx/bridge.env.

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)

	// Bridge-specific fields (Idea 46.3)
	BridgeMode   BridgeMode        // for RuntimeBridge nodes
	BridgeConfig *BridgeNodeConfig // bridge-specific parameters
	// 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"
	RuntimeBridge     Runtime = "bridge" // Idea 46.3: hybrid bridge services
)

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