Documentation
¶
Index ¶
- func CancelDisposerBundle(closers ...Cancelable)
- func CloserDisposerBundle(closers ...io.Closer)
- func DisposerBundle(disposers ...any)
- func Get[Type any](c Interface) Type
- func Injectable(v ...interface{}) uint
- func NewIOCloserProvider(v io.Closer) (closer *ioCloserProvider)
- func NewPoolProvider(pool *sync.Pool, v interface{}) (pooler *poolerProvider)
- func Set[Type any](c ContainerAware, val Type) (err error)
- func SetProvider[Type any](c Interface, builder func(registry Interface) Type) (err error)
- func TypeOf(i interface{}) reflect.Type
- func TypeOfElem(i interface{}) reflect.Type
- type Cancelable
- type ContainerAware
- type Definer
- type Disposer
- type Initializer
- type InitializerFunc
- type Interface
- type LifeCycle
- type Provider
- type ProviderFunc
- type Registry
- func (r *Registry) Autowire(target interface{})
- func (r *Registry) Container() Interface
- func (r *Registry) Dispose() int64
- func (r *Registry) Fork() Interface
- func (r *Registry) InjectValue(value reflect.Value)
- func (r *Registry) Load(dst interface{})
- func (r *Registry) LoadType(typ reflect.Type) (val interface{})
- func (r *Registry) LoadValue(dst reflect.Value)
- func (r *Registry) MapInitializer(typ reflect.Type, initializer Initializer)
- func (r *Registry) MapInitializerFunc(typ reflect.Type, initializer InitializerFunc)
- func (r *Registry) MapProvider(typ reflect.Type, provider Provider)
- func (r *Registry) MustDispose()
- func (r *Registry) WithTypeAndProviderFunc(typ reflect.Type, provider ProviderFunc)
- func (r *Registry) WithTypeAndValue(typOf reflect.Type, value interface{})
- func (r *Registry) WithValues(values ...interface{})
- type TypeDefinition
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CancelDisposerBundle ¶
func CancelDisposerBundle(closers ...Cancelable)
func CloserDisposerBundle ¶
func DisposerBundle ¶
func DisposerBundle(disposers ...any)
func Injectable ¶
func Injectable(v ...interface{}) uint
Injectable marks the type as field to be injectable while searching for fields to inject
func NewIOCloserProvider ¶
func NewPoolProvider ¶
func Set ¶
func Set[Type any](c ContainerAware, val Type) (err error)
func SetProvider ¶
func TypeOfElem ¶
Types ¶
type Cancelable ¶
type Cancelable interface {
Cancel() error
}
type ContainerAware ¶
type ContainerAware interface {
Container() Interface
}
type Definer ¶
type Definer[Type any] interface { Config(d TypeDefinition[Type]) error }
type Initializer ¶
type InitializerFunc ¶
type Interface ¶
type Interface interface { // Container returns the underlying Registry Container() Interface // Load loads a value into the provided destination Load(dst interface{}) // LoadValue loads a value into the provided reflect.Value LoadValue(dst reflect.Value) // Autowire walks the target looking for exported fields that match injectable types Autowire(target interface{}) // InjectValue walks the struct value looking for injectable fields InjectValue(value reflect.Value) // MapProvider maps a provider for a type MapProvider(typ reflect.Type, provider Provider) // WithTypeAndProviderFunc maps a provider function for a type WithTypeAndProviderFunc(typ reflect.Type, provider ProviderFunc) // MapInitializer maps an initializer for a type MapInitializer(typ reflect.Type, initializer Initializer) // MapInitializerFunc maps an initializer function for a type MapInitializerFunc(typ reflect.Type, initializer InitializerFunc) // WithTypeAndValue sets a value for a type WithTypeAndValue(typOf reflect.Type, value interface{}) // WithValues puts a list of values into the current context WithValues(values ...interface{}) // Fork creates a new registry using the current one as parent Fork() Interface // LoadType returns a value for the specified type LoadType(typ reflect.Type) interface{} // Dispose releases all resources and returns the reference count Dispose() int64 // MustDispose disposes and requires all references to be cleared MustDispose() }
Interface registry defines the contract for the registry.Registry type
type ProviderFunc ¶
type ProviderFunc func(c Interface) interface{}
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func (*Registry) Autowire ¶
func (r *Registry) Autowire(target interface{})
Autowire walks the target looking the for exported fields that types match injectable types in Registry
func (*Registry) Dispose ¶
Dispose call end when the request is not need any more, this will cause all finalizers to run, this will my cause parent scopes to end also, this will happen case the parent scopes already ended but is waiting all children to end
func (*Registry) Fork ¶
Fork creates a new context using current value's repository as provider for the new context
func (*Registry) InjectValue ¶
InjectValue walks the struct value looking to injectable fields
func (*Registry) MapInitializer ¶
func (r *Registry) MapInitializer(typ reflect.Type, initializer Initializer)
func (*Registry) MapInitializerFunc ¶
func (r *Registry) MapInitializerFunc(typ reflect.Type, initializer InitializerFunc)
func (*Registry) MustDispose ¶
func (r *Registry) MustDispose()
MustDispose works same as Close, but require that all children to be terminated when called
func (*Registry) WithTypeAndProviderFunc ¶
func (r *Registry) WithTypeAndProviderFunc(typ reflect.Type, provider ProviderFunc)
func (*Registry) WithTypeAndValue ¶
WithTypeAndValue sets a provider for the type of typ with value of val
func (*Registry) WithValues ¶
func (r *Registry) WithValues(values ...interface{})
WithValues puts the list of values into the current context
type TypeDefinition ¶
type TypeDefinition[Type any] struct { // contains filtered or unexported fields }