container

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2024 License: MIT Imports: 7 Imported by: 22

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitContainer

func InitContainer()

func IsRegister added in v0.5.0

func IsRegister[TInterface any](iocName ...string) bool

IsRegister 是否注册过

func IsRegisterType added in v0.12.0

func IsRegisterType(interfaceType reflect.Type, iocName ...string) bool

IsRegisterType 判断类型是否注册过

func NewComponentModel added in v0.4.0

func NewComponentModel(name string, lifecycle eumLifecycle.Enum, interfaceType reflect.Type, funcIns any) *componentModel

func NewComponentModelByInstance added in v0.4.0

func NewComponentModelByInstance(name string, lifecycle eumLifecycle.Enum, interfaceType reflect.Type, instance any) *componentModel

func NewContainer added in v0.4.0

func NewContainer() *container

NewContainer 实例化一个默认容器

func Register

func Register(constructor any, iocName ...string)

Register 注册实例,默认使用单例

func RegisterInstance added in v0.4.0

func RegisterInstance[TInterface any](ins TInterface, iocName ...string)

RegisterInstance 注册实例,默认使用单例

func RegisterTransient added in v0.4.0

func RegisterTransient(constructor any, iocName ...string)

RegisterTransient 注册实例,默认使用单例

func Remove added in v0.8.0

func Remove[TInterface any](iocName ...string)

Remove 移除已注册的实例

func RemoveUnused added in v0.8.0

func RemoveUnused[TInterface any](ttl time.Duration)

RemoveUnused 移除长时间未使用的实例

func Resolve

func Resolve[TInterface any](iocName ...string) TInterface

Resolve 从容器中获取实例 iocName = 别名

func ResolveAll added in v0.7.0

func ResolveAll[TInterface any]() []TInterface

ResolveAll 从容器中获取所有实例

func ResolveIns added in v0.7.0

func ResolveIns[TIns any](ins TIns) TIns

ResolveIns 将现有中实例内的字段做注入操作

func ResolveType added in v0.5.0

func ResolveType(interfaceType reflect.Type, iocName ...string) (any, error)

ResolveType 从容器中获取实例 interfaceType = interface type iocName = 别名

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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