Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ContainerField ¶
ContainerField represents an injectable field in a Container struct.
Note: - Name can be "_" for override-only fields. - Type is the type to be provided (e.g. service.User, infra.Database).
func ConvertContainerFields ¶
func ConvertContainerFields(c scan.ContainerSpec) ([]ContainerField, error)
ConvertContainerFields converts a scanned ContainerSpec into resolve-ready fields.
Resolution target rules:
- If the Container has at least one `inject`-marked *public field* (non-blank), only those marked fields are included.
- Blank fields ("_") are treated as provider overrides and do NOT switch the container into explicit mode. They are included only when they are `inject`-marked.
type Graph ¶
type Graph struct {
Roots []*Node
}
Graph represents a resolved dependency graph.
func BuildGraph ¶
func BuildGraph(fields []ContainerField, providers []*Provider) (*Graph, error)
BuildGraph resolves dependencies starting from container fields.
type InjectTag ¶
type InjectTag struct {
// Provider selects a specific provider function by name.
// Example: `inject:"provider:service.NewUser"`
Provider string
}
InjectTag is a parsed `inject` struct tag for Container fields.
type Node ¶
Node represents a node in the resolved dependency graph.
Each node corresponds to exactly one Provider. Nodes may be shared across the graph to represent a DAG (i.e. the same Provider can be depended on by multiple parents).
type Provider ¶
type Provider struct {
PkgPath string
Name string
NameWithPkg string
ResultType types.Type
ReturnError bool
Params []types.Type
Position string
}
Provider represents a constructor function that can produce a value for dependency injection.
A Provider is identified by its identity (pointer equality), not by value. It is treated as immutable during resolution and is shared across the dependency graph for cycle detection and override resolution.
func ConvertProviders ¶
func ConvertProviders(ps []scan.ProviderSpec) ([]*Provider, error)
ConvertProviders converts scanned ProviderDecl into resolve Provider nodes.
func OrderProviders ¶
OrderProviders returns providers in topological order (dependencies first). Providers may appear only once even if referenced multiple times by roots.