Documentation
¶
Overview ¶
Package kernel provides the dependency injection container and module bootstrapping logic.
Index ¶
- Variables
- type App
- type Container
- type ControllerBuildError
- type DuplicateControllerNameError
- type DuplicateModuleNameError
- type DuplicateProviderTokenError
- type ExportAmbiguousError
- type ExportNotVisibleError
- type Graph
- type InvalidModuleDefError
- type InvalidModuleNameError
- type ModuleCycleError
- type ModuleNode
- type ModuleNotPointerError
- type NilImportError
- type ProviderBuildError
- type ProviderCycleError
- type ProviderNotFoundError
- type RootModuleNilError
- type TokenNotVisibleError
- type Visibility
Constants ¶
This section is empty.
Variables ¶
var ErrExportAmbiguous = errors.New("export token is ambiguous across imports")
ErrExportAmbiguous is returned when a module tries to re-export a token that multiple imports provide.
var ErrNilGraph = errors.New("graph is nil")
ErrNilGraph is returned when BuildVisibility is called with a nil graph.
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct {
Graph *Graph
Controllers map[string]any
// contains filtered or unexported fields
}
App represents a bootstrapped modkit application with its dependency graph, container, and instantiated controllers.
func Bootstrap ¶
Bootstrap constructs a modkit application from a root module. It builds the module graph, validates dependencies, creates the DI container, and instantiates all controllers.
func (*App) CleanupHooks ¶ added in v0.4.0
CleanupHooks returns provider cleanup hooks in LIFO order.
func (*App) Close ¶ added in v0.5.0
Close closes providers implementing io.Closer in reverse build order.
func (*App) CloseContext ¶ added in v0.7.0
CloseContext closes providers implementing io.Closer in reverse build order.
type Container ¶
type Container struct {
// contains filtered or unexported fields
}
Container is the dependency injection container that manages provider instances, enforces visibility rules, and tracks cleanup hooks.
type ControllerBuildError ¶
ControllerBuildError wraps an error that occurred while building a controller instance.
func (*ControllerBuildError) Error ¶
func (e *ControllerBuildError) Error() string
func (*ControllerBuildError) Unwrap ¶
func (e *ControllerBuildError) Unwrap() error
type DuplicateControllerNameError ¶
DuplicateControllerNameError is returned when a module has multiple controllers with the same name.
func (*DuplicateControllerNameError) Error ¶
func (e *DuplicateControllerNameError) Error() string
type DuplicateModuleNameError ¶
type DuplicateModuleNameError struct {
Name string
}
DuplicateModuleNameError is returned when multiple modules have the same name.
func (*DuplicateModuleNameError) Error ¶
func (e *DuplicateModuleNameError) Error() string
type DuplicateProviderTokenError ¶
DuplicateProviderTokenError is returned when the same provider token is registered in multiple modules.
func (*DuplicateProviderTokenError) Error ¶
func (e *DuplicateProviderTokenError) Error() string
type ExportAmbiguousError ¶ added in v0.6.0
ExportAmbiguousError is returned when a module re-exports a token that multiple imports provide.
func (*ExportAmbiguousError) Error ¶ added in v0.6.0
func (e *ExportAmbiguousError) Error() string
func (*ExportAmbiguousError) Unwrap ¶ added in v0.6.0
func (e *ExportAmbiguousError) Unwrap() error
type ExportNotVisibleError ¶
ExportNotVisibleError is returned when a module exports a token it cannot access.
func (*ExportNotVisibleError) Error ¶
func (e *ExportNotVisibleError) Error() string
type Graph ¶
type Graph struct {
Root string
Modules []ModuleNode
Nodes map[string]*ModuleNode
}
Graph represents the complete module dependency graph with all nodes and import relationships.
type InvalidModuleDefError ¶
InvalidModuleDefError is returned when a module's Definition() returns invalid metadata.
func (*InvalidModuleDefError) Error ¶
func (e *InvalidModuleDefError) Error() string
func (*InvalidModuleDefError) Unwrap ¶
func (e *InvalidModuleDefError) Unwrap() error
type InvalidModuleNameError ¶
type InvalidModuleNameError struct {
Name string
}
InvalidModuleNameError is returned when a module has an empty or invalid name.
func (*InvalidModuleNameError) Error ¶
func (e *InvalidModuleNameError) Error() string
type ModuleCycleError ¶
type ModuleCycleError struct {
Path []string
}
ModuleCycleError is returned when a circular dependency exists in module imports.
func (*ModuleCycleError) Error ¶
func (e *ModuleCycleError) Error() string
type ModuleNode ¶
ModuleNode represents a module in the dependency graph with its definition and import names.
type ModuleNotPointerError ¶
type ModuleNotPointerError struct {
Module string
}
ModuleNotPointerError is returned when a module is not passed by pointer.
func (*ModuleNotPointerError) Error ¶
func (e *ModuleNotPointerError) Error() string
type NilImportError ¶
NilImportError is returned when a module has a nil entry in its Imports slice.
func (*NilImportError) Error ¶
func (e *NilImportError) Error() string
type ProviderBuildError ¶
ProviderBuildError wraps an error that occurred while building a provider instance.
func (*ProviderBuildError) Error ¶
func (e *ProviderBuildError) Error() string
func (*ProviderBuildError) Unwrap ¶
func (e *ProviderBuildError) Unwrap() error
type ProviderCycleError ¶
ProviderCycleError is returned when a circular dependency exists in provider resolution.
func (*ProviderCycleError) Error ¶
func (e *ProviderCycleError) Error() string
type ProviderNotFoundError ¶
ProviderNotFoundError is returned when attempting to resolve a token that has no registered provider.
func (*ProviderNotFoundError) Error ¶
func (e *ProviderNotFoundError) Error() string
type RootModuleNilError ¶
type RootModuleNilError struct{}
RootModuleNilError is returned when Bootstrap is called with a nil root module.
func (*RootModuleNilError) Error ¶
func (e *RootModuleNilError) Error() string
type TokenNotVisibleError ¶
TokenNotVisibleError is returned when a module attempts to resolve a token that isn't visible to it.
func (*TokenNotVisibleError) Error ¶
func (e *TokenNotVisibleError) Error() string
type Visibility ¶
Visibility represents which provider tokens are accessible from each module. The outer map key is the module name, the inner map contains visible tokens.
func BuildVisibility ¶ added in v0.6.0
func BuildVisibility(graph *Graph) (Visibility, error)
BuildVisibility constructs the visibility map for all modules in the graph, ensuring exports are valid and detecting ambiguous re-exports.