ioc

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GracefulShutdown

func GracefulShutdown(ctx context.Context, wg *sync.WaitGroup)

func Inject

func Inject[T any](name ...string) func() T

Inject bean by type and (optionaly) name

Types

type ApplicationContext

type ApplicationContext struct {
	// contains filtered or unexported fields
}

func ApplicationContextInstance

func ApplicationContextInstance() *ApplicationContext

func (*ApplicationContext) Bean

func (c *ApplicationContext) Bean(inject *InjectQualifier[any]) any

func (*ApplicationContext) Close added in v1.0.2

func (c *ApplicationContext) Close()

func (*ApplicationContext) Register

func (c *ApplicationContext) Register(bean BeanDefinition)

type BeanDefinition

type BeanDefinition interface {
	String() string
	// contains filtered or unexported methods
}

type BeanDefinitionImpl

type BeanDefinitionImpl[T any] struct {
	// contains filtered or unexported fields
}

func Bean

func Bean[T any]() *BeanDefinitionImpl[T]

Register bean

func (*BeanDefinitionImpl[T]) Factory

func (b *BeanDefinitionImpl[T]) Factory(f func() *T) *BeanDefinitionImpl[T]

Set the factory method reference or anonymous function with actual implementation

func (*BeanDefinitionImpl[T]) Name

func (b *BeanDefinitionImpl[T]) Name(names ...string) *BeanDefinitionImpl[T]

Set optional name(s)

func (*BeanDefinitionImpl[T]) PostConstruct

func (b *BeanDefinitionImpl[T]) PostConstruct(f func(*T)) *BeanDefinitionImpl[T]

It is safe to use injected beans at this point

func (*BeanDefinitionImpl[T]) PreDestroy

func (b *BeanDefinitionImpl[T]) PreDestroy(f func(*T)) *BeanDefinitionImpl[T]

Clean-up resources before shutdown. Not called on prototype beans.

func (*BeanDefinitionImpl[T]) Primary

func (b *BeanDefinitionImpl[T]) Primary() *BeanDefinitionImpl[T]

Mark this bean as primary

func (*BeanDefinitionImpl[T]) Profile added in v1.0.1

func (b *BeanDefinitionImpl[T]) Profile(profileExpr ...string) *BeanDefinitionImpl[T]

Profile binding

func (*BeanDefinitionImpl[T]) Register

func (b *BeanDefinitionImpl[T]) Register()

Register the bean within the context

func (*BeanDefinitionImpl[T]) Scope

func (b *BeanDefinitionImpl[T]) Scope(scope string) *BeanDefinitionImpl[T]

Set optional scope

func (*BeanDefinitionImpl[T]) String

func (b *BeanDefinitionImpl[T]) String() string

Implements String

type InjectQualifier

type InjectQualifier[T any] struct {
	// contains filtered or unexported fields
}

func (*InjectQualifier[T]) Name

func (i *InjectQualifier[T]) Name(name string) *InjectQualifier[T]

type Profile

type Profile string

type Scope

type Scope int
const (
	Singleton Scope = iota
	Prototype
)

Jump to

Keyboard shortcuts

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