resolve

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package resolve turns a parsed graph into a topologically ordered build plan. Resolution is memoized, detects cycles, and reports missing or ambiguous providers with a full dependency path.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Plan

type Plan struct {
	Graph *model.Graph
	Root  *Step
	// Steps are ordered so that every dependency precedes its dependents.
	Steps []*Step
	// contains filtered or unexported fields
}

Plan is the resolved build order for a graph.

func Build

func Build(g *model.Graph, lifecycle, contextType types.Type, base string) (*Plan, error)

Build resolves g into a plan. lifecycle and contextType are the framework types that are always injectable; either may be nil. base is used to render source paths in diagnostics.

func (*Plan) HasCleanup

func (p *Plan) HasCleanup() bool

HasCleanup reports whether any provider in the plan returns a cleanup function. Generated code only emits rollback logic when it might be needed.

func (*Plan) HasError

func (p *Plan) HasError() bool

HasError reports whether any provider in the plan can fail.

func (*Plan) StepFor

func (p *Plan) StepFor(t types.Type) (*Step, bool)

StepFor returns the step that satisfies t.

type Step

type Step struct {
	Kind     StepKind
	Provider *model.Provider
	// Type is the type this step produces.
	Type types.Type
	// Deps are the steps that must run before this one, in input order.
	Deps []*Step
	// Pos is the source position of the provider, if any.
	Pos token.Position
}

Step is one node of an ordered build plan.

type StepKind

type StepKind uint8

StepKind identifies what a step produces.

const (
	// StepProvider invokes a registered provider.
	StepProvider StepKind = iota
	// StepLifecycle is the *loom.Lifecycle created by generated code.
	StepLifecycle
	// StepContext is the context.Context passed to generated code.
	StepContext
)

Jump to

Keyboard shortcuts

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