Documentation
¶
Overview ¶
Package appconfiggraph builds the component dependency graph of an install's pinned app config and resolves effective-enabled state and cascade ordering over it. It is pure graph logic: given the config-connection snapshot and the install's enabled inputs, it answers which components should be deployed and in what order, with no database, FX, or queue dependencies. The install workflow step generator and the service-side toggle validation share it.
The package is split into two layers: Graph holds the pure dependency structure (see graph.go), and ComponentEnablementResolver overlays the install's per-component toggles on top of a Graph to resolve effective-enabled state.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ComponentEnablementResolver ¶
type ComponentEnablementResolver struct {
*Graph
// contains filtered or unexported fields
}
ComponentEnablementResolver overlays an install's per-component toggles on a Graph to resolve the effective-enabled state of each component. A component is effectively enabled only when its own toggle is on (non-toggleable components are always own-enabled) AND every component it depends on is effectively enabled:
effectiveEnabled(C) = ownEnabled(C) && all(effectiveEnabled(dep) for dep in deps(C))
Own-enabled state is sourced from the install's inputs via the reserved synthetic enabled input (see ComponentEnabledFromInputs), which is the single source of truth for a component's toggle. The embedded *Graph supplies the structural queries (DepEdges, DirectDependents, TopoSort, etc.).
func NewComponentEnablementResolver ¶
func NewComponentEnablementResolver(cccByID map[string]*app.ComponentConfigConnection, enabledInputs map[string]*string) *ComponentEnablementResolver
NewComponentEnablementResolver builds a resolver from a component-ID keyed set of config connections (the install's pinned app config snapshot) and the install's latest input values, which carry the per-component enabled toggles.
func (*ComponentEnablementResolver) DisabledDependencies ¶
func (r *ComponentEnablementResolver) DisabledDependencies(compID string) []string
DisabledDependencies returns the direct dependencies of compID that are not effectively enabled. Used to build user-facing "enable X first" errors.
func (*ComponentEnablementResolver) EffectiveEnabled ¶
func (r *ComponentEnablementResolver) EffectiveEnabled(compID string) bool
EffectiveEnabled reports whether the component should be deployed given its own toggle and its dependency closure. Results are memoized; the visiting set guards against cycles defensively (the app config graph is a DAG).
func (*ComponentEnablementResolver) OwnEnabled ¶
func (r *ComponentEnablementResolver) OwnEnabled(compID string) bool
OwnEnabled reports whether the component's own toggle is on, ignoring its dependency closure. Non-toggleable components are always own-enabled.
type Graph ¶
type Graph struct {
// contains filtered or unexported fields
}
Graph is the dependency graph of the components in an install's pinned app config. An edge C -> D means C depends on D, where dependencies are the UNION of declared dependencies (ComponentDependencyIDs) and components whose outputs C references (Refs of type component), scoped to the components present in the provided set. It is pure structure: it carries no toggle/enabled state and has no database, FX, or queue dependencies. Effective-enabled resolution is layered on top by ComponentEnablementResolver.
func NewGraph ¶
func NewGraph(cccByID map[string]*app.ComponentConfigConnection) *Graph
NewGraph builds the dependency graph from a component-ID keyed set of config connections (the install's pinned app config snapshot).
func (*Graph) DepEdges ¶
DepEdges returns the union dependency set (deps + output refs) per component.
func (*Graph) DirectDependents ¶
DirectDependents returns the components that directly declare compID as a dependency (the reverse of DepEdges for a single node).
func (*Graph) ReverseTopoSort ¶
ReverseTopoSort orders ids so dependents come before the dependencies they rely on (teardown order).
func (*Graph) TopoSort ¶
TopoSort orders ids so dependencies come before the components that depend on them (deploy order). Ties (components with no in-set dependency between them) preserve the caller's input order, so unrelated components are not reordered.
func (*Graph) TransitiveDependentsClosure ¶
TransitiveDependentsClosure returns the given roots plus every component that transitively depends on any root (the blast radius of toggling those roots).