Documentation
¶
Index ¶
- Constants
- type ArgContext
- func (a *ArgContext) Bind(v reflect.Value, tag string) error
- func (a *ArgContext) Check(c gs.Condition) (bool, error)
- func (a *ArgContext) Find(s gs.BeanSelector) ([]gs.ConditionBean, error)
- func (a *ArgContext) Has(key string) bool
- func (a *ArgContext) Prop(key string, def ...string) string
- func (a *ArgContext) Wire(v reflect.Value, tag string) error
- type BeanRuntime
- type Injecting
- type Injector
- type LazyField
- type Stack
- type WireTag
Constants ¶
const ( RefreshDefault = refreshState(iota) // Not refreshed yet Refreshing // Currently refreshing Refreshed // Successfully refreshed )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArgContext ¶
type ArgContext struct {
// contains filtered or unexported fields
}
ArgContext provides runtime context when calling bean factory functions. It exposes access to configuration properties, bean lookups, condition checks, and allows wiring of parameters during construction.
func NewArgContext ¶
func NewArgContext(c *Injector, stack *Stack) *ArgContext
NewArgContext constructs a new ArgContext for a wiring operation.
func (*ArgContext) Bind ¶
func (a *ArgContext) Bind(v reflect.Value, tag string) error
Bind binds configuration data into the provided reflect.Value based on the given struct tag.
func (*ArgContext) Check ¶
func (a *ArgContext) Check(c gs.Condition) (bool, error)
Check evaluates a condition against the current ArgContext.
func (*ArgContext) Find ¶
func (a *ArgContext) Find(s gs.BeanSelector) ([]gs.ConditionBean, error)
Find retrieves beans matching the given selector.
func (*ArgContext) Has ¶
func (a *ArgContext) Has(key string) bool
Has checks whether a configuration key is present.
type BeanRuntime ¶
type BeanRuntime interface { Name() string // The name of the bean Type() reflect.Type // The reflect.Type of the bean Value() reflect.Value // The reflect.Value of the bean Interface() any // The underlying Go interface of the bean Callable() *gs_arg.Callable // Optional constructor or factory metadata Status() gs_bean.BeanStatus // Lifecycle status of the bean String() string // A readable string representation }
BeanRuntime defines an interface that provides runtime metadata.
type Injecting ¶
type Injecting struct {
// contains filtered or unexported fields
}
Injecting is the IoC component that handles dependency injection and lifecycle management for beans once they have been resolved.
func (*Injecting) Close ¶
func (c *Injecting) Close()
Close shuts down the container by invoking all registered destroyer callbacks in reverse registration order, ensuring dependent resources are released safely.
func (*Injecting) Refresh ¶
func (c *Injecting) Refresh(roots, beans []*gs_bean.BeanDefinition) (err error)
Refresh wires all provided beans and prepares them for use.
It performs the following steps:
- Builds indexes for bean lookup by name and type.
- Wires root beans (entry points of the dependency graph).
- Handles lazy wiring for circular dependencies if allowed.
- Captures all registered destroyer callbacks for proper shutdown order.
- Optionally cleans up metadata if running outside testing.
func (*Injecting) RefreshProperties ¶
func (c *Injecting) RefreshProperties(p conf.Properties) error
RefreshProperties updates the dynamic property source for the container.
type Injector ¶
type Injector struct {
// contains filtered or unexported fields
}
Injector is the component that executes core autowiring and bean lifecycle management (constructor, field, and method injection).
type LazyField ¶
type LazyField struct {
// contains filtered or unexported fields
}
LazyField represents a field in a struct that should be injected lazily.
type Stack ¶
type Stack struct {
// contains filtered or unexported fields
}
Stack represents the runtime context during bean wiring. It keeps track of the current wiring call stack, lazily injected fields, and the ordering of destroyers for proper shutdown.