gs_init

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: May 4, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddBean

func AddBean(bean *gs_bean.BeanDefinition)

AddBean registers a new bean definition in the global registry. This function adds beans to the global scope (package-level), making them available for all App/IOC containers that reference this global registry.

func AddModule

func AddModule(c gs_cond.PropertyCondition, fn ModuleFunc, file string, line int)

AddModule registers a conditional module in the global registry. This is called by starter/autoconfiguration code to register a module that should only activate when its condition matches the application configuration.

func Beans

func Beans() []*gs_bean.BeanDefinition

Beans returns all registered bean definitions.

In test mode, it returns cloned BeanDefinitions to avoid mutating shared bean definitions during test execution.

func Clear

func Clear()

Clear resets all registered beans and modules, effectively emptying the global registry. This function is primarily used for testing purposes to ensure test isolation by clearing the global state between test runs.

Types

type BeanProvider

type BeanProvider interface {
	Provide(objOrCtor any, args ...gs.Arg) *gs_bean.BeanDefinition
}

BeanProvider defines the API for registering beans in the IoC container. It serves as the abstraction for bean registration, allowing different container implementations to accept bean definitions uniformly.

type Module

type Module struct {
	ModuleFunc ModuleFunc
	Condition  gs.Condition
	FileLine   string
}

Module represents a conditional module that can register beans when its Condition is satisfied.

func Modules

func Modules() []Module

Modules returns all registered modules.

type ModuleFunc

type ModuleFunc func(r BeanProvider, p flatten.Storage) error

ModuleFunc defines the signature of a module function that registers beans using a BeanProvider. The function receives a set of configuration properties as input.

ModuleFunc is the core mechanism for implementing starter-like functionality: - A single ModuleFunc can register multiple related beans atomically - This enables auto-configuration patterns similar to Java Spring Boot starters - Modules can be conditionally activated based on configuration properties

Jump to

Keyboard shortcuts

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