Documentation
¶
Index ¶
- Constants
- type ConditionContext
- type Module
- type RefreshState
- type Resolving
- func (c *Resolving) AddMock(mock gs.BeanMock)
- func (c *Resolving) Beans() []*gs_bean.BeanDefinition
- func (c *Resolving) Module(conditions []gs_cond.ConditionOnProperty, fn func(p conf.Properties) error)
- func (c *Resolving) Object(i any) *gs.RegisteredBean
- func (c *Resolving) Provide(ctor any, args ...gs.Arg) *gs.RegisteredBean
- func (c *Resolving) Refresh(p conf.Properties) error
- func (c *Resolving) Register(b *gs.BeanDefinition) *gs.RegisteredBean
- func (c *Resolving) Root(b *gs.RegisteredBean)
- func (c *Resolving) Roots() []*gs_bean.BeanDefinition
Constants ¶
const ( RefreshDefault = RefreshState(iota) RefreshPrepare Refreshing Refreshed )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConditionContext ¶ added in v1.2.3
type ConditionContext struct {
// contains filtered or unexported fields
}
ConditionContext provides an evaluation context for conditions during bean resolution.
func (*ConditionContext) Find ¶ added in v1.2.3
func (c *ConditionContext) Find(s gs.BeanSelector) ([]gs.ConditionBean, error)
Find returns all beans that match the provided selector and are successfully resolved (active).
func (*ConditionContext) Has ¶ added in v1.2.3
func (c *ConditionContext) Has(key string) bool
Has checks if a configuration property exists.
type Module ¶ added in v1.2.3
type Module struct {
// contains filtered or unexported fields
}
Module represents a module that can register additional beans when certain conditions are met.
type RefreshState ¶
type RefreshState int
RefreshState represents the current state of the container.
type Resolving ¶
type Resolving struct {
// contains filtered or unexported fields
}
Resolving is the core container responsible for holding bean definitions, processing modules, applying mocks, scanning configuration beans, and resolving beans against conditions.
func (*Resolving) AddMock ¶
AddMock registers a mock bean which can override an existing bean during the refresh phase.
func (*Resolving) Beans ¶
func (c *Resolving) Beans() []*gs_bean.BeanDefinition
Beans returns all active bean definitions, excluding deleted ones.
func (*Resolving) Module ¶ added in v1.2.3
func (c *Resolving) Module(conditions []gs_cond.ConditionOnProperty, fn func(p conf.Properties) error)
Module registers a conditional module that will be executed to add beans before the container starts refreshing.
func (*Resolving) Object ¶
func (c *Resolving) Object(i any) *gs.RegisteredBean
Object registers a pre-constructed instance as a bean definition.
func (*Resolving) Provide ¶
Provide registers a constructor function and optional arguments as a bean.
func (*Resolving) Refresh ¶
func (c *Resolving) Refresh(p conf.Properties) error
Refresh performs the full lifecycle of container initialization. The phases are as follows:
- Apply registered modules to register additional beans.
- Scan configuration beans and register methods as beans.
- Apply mock beans to override specific target beans.
- Resolve conditions for all beans and mark inactive ones as deleted.
- Check for duplicate beans (by type and name).
- Validate that all root beans are resolved and ready to wire.
func (*Resolving) Register ¶
func (c *Resolving) Register(b *gs.BeanDefinition) *gs.RegisteredBean
Register adds a bean definition to the container. It must be called before the container starts refreshing.
func (*Resolving) Root ¶ added in v1.2.5
func (c *Resolving) Root(b *gs.RegisteredBean)
Root marks a registered bean as a root bean.
func (*Resolving) Roots ¶ added in v1.2.3
func (c *Resolving) Roots() []*gs_bean.BeanDefinition
Roots returns all root beans.