Documentation ¶
Index ¶
- Constants
- Variables
- func AcquireInfrastructure()
- func AcquireSingleton[T any](iface T) T
- func AcquireSingletonByName[T any](name string) T
- func ContainerProvide[T any](c *Container) (T, bool)
- func Load[T any](val T) T
- func MustRegister[T any](val T, err error) T
- func Register[T any](val T) T
- func RegisterConfig(config config.ConfigUnmarshaler)
- func RegisterLogger(logger logger.ILogger)
- func RegisterSingleton[T any](singleton interface{})
- func RegisterSingletonByName(name string, singleton interface{})
- func RegisterTaskDispatcher(taskDispatcher asynctask.TaskDispatcher)
- func TryInject[T any](injectable T) T
- func Use[T any](val T) T
- func Validate()
- type Container
- type Dependency
- type Provider
- type Registrant
- type Registry
- type SingletonProvider
Constants ¶
View Source
const InjectTag = "aperture"
Variables ¶
View Source
var Config config.ConfigUnmarshaler
View Source
var EmptyContext = context.Background()
View Source
var Logger logger.ILogger
View Source
var TaskDispatcher asynctask.TaskDispatcher = nil
Functions ¶
func AcquireInfrastructure ¶
func AcquireInfrastructure()
func AcquireSingleton ¶
func AcquireSingleton[T any](iface T) T
func AcquireSingletonByName ¶
func ContainerProvide ¶
func Load ¶
func Load[T any](val T) T
Load is a shortcut for TryInject(val) Load will also check if val can add to registry
func MustRegister ¶
func RegisterConfig ¶
func RegisterConfig(config config.ConfigUnmarshaler)
func RegisterLogger ¶
func RegisterSingleton ¶
func RegisterSingleton[T any](singleton interface{})
func RegisterSingletonByName ¶
func RegisterSingletonByName(name string, singleton interface{})
func RegisterTaskDispatcher ¶
func RegisterTaskDispatcher(taskDispatcher asynctask.TaskDispatcher)
Types ¶
type Container ¶
type Container struct {
// contains filtered or unexported fields
}
func NewContainer ¶
func (*Container) ContainerName ¶
type Dependency ¶
type Dependency[T any] interface { Inject(T) }
type Registrant ¶
type Registrant func(impl any)
type Registry ¶
type Registry[I comparable, T any] interface { Register(impl T) RegisterByEntry(entry I, impl T) Acquire(impl T) T AcquireByEntry(entry I) T AcquireAll() []T }
var DBConfig Registry[string, *model.DatabaseConfig]
var Disposable Registry[int, scene.Disposable]
var Repository Registry[string, scene.Repository] var Service Registry[string, scene.Service]
func NewOrderedRegistry ¶
func NewOrderedRegistry[I constraints.Ordered, T any](naming naming[I, T]) Registry[I, T]
func NewRegistry ¶
func NewRegistry[I comparable, T any](naming naming[I, T]) Registry[I, T]
type SingletonProvider ¶
type SingletonProvider[T any] struct { // contains filtered or unexported fields }
func NewSingletonProvider ¶
func NewSingletonProvider[T any](instance T) *SingletonProvider[T]
func (*SingletonProvider[T]) Provide ¶
func (p *SingletonProvider[T]) Provide() T
Click to show internal directories.
Click to hide internal directories.