Documentation
¶
Index ¶
- Constants
- Variables
- type Category
- type ConfigEntry
- type ConfigResolver
- type Container
- type Handle
- type InOption
- type LoadOption
- type LoadOptions
- type Locator
- type ModuleConfig
- type Priority
- type Provider
- type RegisterOption
- type Registration
- type RegistrationOptions
- type Registry
- type RequirementResolver
- type Scope
Constants ¶
View Source
const ( // ReservedPrefix defines identifiers owned by the system. ReservedPrefix = "_" // DefaultName defines the name of the default component instance. DefaultName = "_default" )
Variables ¶
View Source
var ( // ErrRequirementNotFound is returned when a requested requirement is not found. ErrRequirementNotFound = errors.New("engine: requirement not found") )
Functions ¶
This section is empty.
Types ¶
type ConfigEntry ¶
type ConfigEntry struct {
Name string
Value any
RequirementResolver RequirementResolver
}
ConfigEntry represents the configuration for a single component instance. RequirementResolver at this level takes precedence over the ModuleConfig level.
type ConfigResolver ¶
type ConfigResolver func(ctx context.Context, source any, opts *LoadOptions) (*ModuleConfig, error)
ConfigResolver resolves raw configuration source into ModuleConfig.
type Container ¶
type Container interface {
Register(cat Category, p Provider, opts ...RegisterOption)
Inject(cat Category, name string, inst any, opts ...RegisterOption)
IsRegistered(cat Category, opts ...RegisterOption) bool
Requirement(cat Category, purpose string, res RequirementResolver)
Load(ctx context.Context, source any, opts ...LoadOption) error
In(cat Category, opts ...InOption) Registry
}
type LoadOption ¶
type LoadOption func(*LoadOptions)
type LoadOptions ¶
type LoadOptions struct {
Category Category
Scope Scope
Name string
Tags []string
Resolver ConfigResolver
}
type Locator ¶
type Locator interface {
Get(ctx context.Context, name string) (any, error)
Iter(ctx context.Context) iterator.Iterator
In(cat Category, opts ...InOption) Registry
WithInScope(s Scope) Locator
WithInTags(tags ...string) Locator
Skip(names ...string) Locator
Category() Category
Scope() Scope
Scopes() []Scope
Tags() []string // Returns the "Package" of identities carried by this locator
}
type ModuleConfig ¶
type ModuleConfig struct {
Entries []ConfigEntry
Active string
RequirementResolver RequirementResolver
}
ModuleConfig represents the configuration for an entire category. RequirementResolver at this level acts as a default for all entries in the category.
type Priority ¶
type Priority int
const ( // PriorityFramework is the lowest priority, used for framework-level defaults. PriorityFramework Priority = 0 // PriorityInfrastructure is used for common infrastructure (DB, Cache, etc). PriorityInfrastructure Priority = 100 // PriorityDefault is the standard priority for business components. PriorityDefault Priority = 200 // PriorityImportant is used for components that should override defaults. PriorityImportant Priority = 300 // PriorityCritical is the highest priority, for emergency overrides. PriorityCritical Priority = 400 )
type RegisterOption ¶
type RegisterOption func(*RegistrationOptions)
type Registration ¶
type Registration struct {
Category Category
Provider Provider
Options []RegisterOption
}
type RegistrationOptions ¶
type RegistrationOptions struct {
Scopes []Scope
Tag string
Priority Priority
DefaultEntries []string
ConfigResolver ConfigResolver
RequirementResolver RequirementResolver
}
type Registry ¶
type Registry interface {
Locator
Register(p Provider, opts ...RegisterOption)
Inject(name string, inst any, opts ...RegisterOption)
IsRegistered(opts ...RegisterOption) bool
Requirement(purpose string, resolver RequirementResolver)
}
type RequirementResolver ¶
Click to show internal directories.
Click to hide internal directories.