provider

package
v0.1.0-preview.8 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package provider builds and validates the compile-time provider catalog.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SelectAutoConfiguration

func SelectAutoConfiguration(
	primary Catalog,
	defaults Catalog,
) (Catalog, []AutoConfigurationDecision)

SelectAutoConfiguration prunes library defaults before application graph construction. Application-owned exact outputs win, and defaults whose required inputs are unavailable back off without being constructed.

func SelectAutoConfigurationWithAvailable

func SelectAutoConfigurationWithAvailable(
	primary Catalog,
	defaults Catalog,
	featureTypes ...types.Type,
) (Catalog, []AutoConfigurationDecision)

SelectAutoConfigurationWithAvailable selects defaults while admitting compiler-owned feature types that enter the final graph after default pruning. The supplied types satisfy dependencies only; they never replace a default output or become generated providers through this selection pass.

func TypeID

func TypeID(value types.Type) string

TypeID returns a deterministic readable Go type string using package import paths rather than source aliases or filesystem paths.

Types

type AutoConfigurationDecision

type AutoConfigurationDecision struct {
	Provider Provider
	Status   AutoConfigurationStatus
	Reason   string
}

AutoConfigurationDecision is one deterministic default-provider outcome.

type AutoConfigurationStatus

type AutoConfigurationStatus string

AutoConfigurationStatus describes why one imported library default was or was not incorporated into the application provider graph.

const (
	AutoConfigurationSelected AutoConfigurationStatus = "selected"
	AutoConfigurationReplaced AutoConfigurationStatus = "replaced"
	AutoConfigurationInactive AutoConfigurationStatus = "inactive"
)

type Catalog

type Catalog struct {
	// contains filtered or unexported fields
}

Catalog is the immutable-by-convention result of validating resolved @Bean annotations from one loaded Program.

func Add

func Add(catalog Catalog, additions ...Provider) Catalog

Add returns a catalog extended with validated compiler-synthesized provider records. It preserves existing diagnostics and rechecks exact output uniqueness across the combined catalog.

func Build

func Build(program *load.Program, resolution resolve.Result) Catalog

Build validates explicit factories, constructible stereotypes, and explicit interface bindings using the exact live symbols and types already owned by program. It never reloads, reflects on, or executes application code.

func BuildEntrypoints

func BuildEntrypoints(program *load.Program, entrypoints []Entrypoint) Catalog

BuildEntrypoints validates explicit starter functions from the same typed Program used for application analysis. It never executes the functions.

func Merge

func Merge(catalogs ...Catalog) Catalog

Merge combines already validated catalogs and rechecks exact output uniqueness across the result.

func (Catalog) Diagnostics

func (c Catalog) Diagnostics() []Diagnostic

Diagnostics returns a defensive copy of deterministic diagnostics.

func (Catalog) Providers

func (c Catalog) Providers() []Provider

Providers returns a defensive copy of deterministic provider records.

type Construction

type Construction string

Construction identifies the generated construction form.

const (
	// ConstructionFactory calls one validated ordinary Go constructor.
	ConstructionFactory Construction = "factory"
	// ConstructionAllocate emits new(T) for one exported concrete struct.
	ConstructionAllocate Construction = "allocate"
)

type Dependency

type Dependency struct {
	Index            int
	Name             string
	Type             types.Type
	TypeID           string
	Position         token.Position
	PhysicalPosition token.Position
	Qualifiers       []string
	Kind             DependencyKind
	Element          types.Type
	ElementTypeID    string
}

Dependency describes one required provider input in declaration order. Type is live semantic data owned by the Program used to build the catalog; TypeID is the deterministic import-path-qualified representation.

func (Dependency) MatchType

func (dependency Dependency) MatchType() types.Type

MatchType returns the exact bean type selected for this constructor input.

type DependencyKind

type DependencyKind string

DependencyKind identifies how generated Go supplies one constructor parameter.

const (
	DependencySingle   DependencyKind = "single"
	DependencySlice    DependencyKind = "slice"
	DependencyMap      DependencyKind = "map"
	DependencyOptional DependencyKind = "optional"
	DependencyLazy     DependencyKind = "lazy"
	DependencyProvider DependencyKind = "provider"
)

type Diagnostic

type Diagnostic struct {
	Position         token.Position
	PhysicalPosition token.Position
	ProviderID       string
	Kind             string
	Message          string
	Fixes            []SuggestedFix
}

Diagnostic is one deterministic source-positioned catalog failure.

func (Diagnostic) Error

func (d Diagnostic) Error() string

Error renders a compiler-style diagnostic.

type Entrypoint

type Entrypoint struct {
	PackagePath   string
	Symbol        string
	SourceID      string
	SourceVersion string
	Source        Source
	Name          string
	Aliases       []string
	Qualifiers    []string
	Primary       bool
	Fallback      bool
	Order         int64
}

Entrypoint identifies one explicitly selected starter provider function.

type InterfaceBinding

type InterfaceBinding struct {
	Expression       string
	Type             types.Type
	TypeID           string
	Position         token.Position
	PhysicalPosition token.Position
}

InterfaceBinding describes one explicit concrete-to-interface exposure. Type is resolved from the annotation source file in the Program's existing type universe; Expression preserves the developer-authored Go spelling.

type Provider

type Provider struct {
	Source           Source
	Role             string
	Construction     Construction
	Symbol           load.Symbol
	Constructor      load.Symbol
	SymbolID         string
	Name             string
	ExplicitName     bool
	Aliases          []string
	Qualifiers       []string
	Primary          bool
	Fallback         bool
	Order            int64
	Scope            sdk.BeanScope
	PackagePath      string
	Position         token.Position
	PhysicalPosition token.Position
	Output           types.Type
	OutputTypeID     string
	Dependencies     []Dependency
	Interfaces       []InterfaceBinding
	ReturnsCleanup   bool
	ReturnsError     bool
	SourceID         string
	SourceVersion    string
}

Provider describes one exact-type construction node. Bean providers call a validated package-level function or configuration method; configuration property providers are synthesized from validated @ConfigurationProperties metadata.

type Source

type Source string

Source identifies how a provider value is constructed.

const (
	// SourceBean identifies a direct package-level or configuration-method
	// @Bean factory call.
	SourceBean Source = "bean"
	// SourceStereotype identifies a constructible @Service, @Controller, or
	// repository stereotype type.
	SourceStereotype Source = "stereotype"
	// SourceConfiguration identifies a generated typed configuration binder.
	SourceConfiguration Source = "configuration"
	// SourceEvent identifies a generated typed event topic marker.
	SourceEvent Source = "event"
	// SourceStarter identifies an explicitly selected starter entrypoint.
	SourceStarter Source = "starter"
	// SourceAutoConfiguration identifies a statically decoded library default
	// selected by an explicit Go import.
	SourceAutoConfiguration Source = "auto-configuration"
	// SourceLogging identifies the compiler-owned fallback *logging.Logger.
	SourceLogging Source = "logging"
)

type SuggestedEdit

type SuggestedEdit struct {
	Position         token.Position
	PhysicalPosition token.Position
	NewText          string
}

SuggestedEdit is one zero-width source insertion or replacement expressed in the loaded program's display and physical coordinate systems.

type SuggestedFix

type SuggestedFix struct {
	Title             string
	AppliesAt         token.Position
	AppliesAtPhysical token.Position
	Edits             []SuggestedEdit
}

SuggestedFix is one provider-owned source repair. The shared diagnostic adapter adds workspace identity and overlay versions without making the provider package depend on an editor transport.

Jump to

Keyboard shortcuts

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