container

package
v0.0.0-...-86833b7 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2023 License: MIT Imports: 6 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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 NewIOCloserProvider(v io.Closer) (closer *ioCloserProvider)

func NewPoolProvider

func NewPoolProvider(pool *sync.Pool, v interface{}) (pooler *poolerProvider)

func TypeOf

func TypeOf(i interface{}) reflect.Type

func TypeOfElem

func TypeOfElem(i interface{}) reflect.Type

Types

type Disposer

type Disposer interface {
	Dispose()
}

type Initializer

type Initializer interface {
	Initialize(c *Registry, value reflect.Value)
}

type InitializerFunc

type InitializerFunc func(c *Registry, value reflect.Value)

type Provider

type Provider interface {
	Provide(c *Registry) interface{}
}

type ProviderFunc

type ProviderFunc func(c *Registry) interface{}

type Registry

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

func New

func New() (r *Registry)

New creates a new instance of context object

func (*Registry) Container

func (r *Registry) Container() *Registry

func (*Registry) Dispose

func (r *Registry) Dispose() int64

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

func (r *Registry) Fork() (child *Registry)

Fork creates a new context using current value's repository as provider for the new context

func (*Registry) Inject

func (r *Registry) Inject(target interface{})

Inject walks the target looking the for exported fields that types match injectable types in Registry

func (*Registry) InjectValue

func (r *Registry) InjectValue(value reflect.Value)

InjectValue walks the struct value looking to injectable fields

func (*Registry) Load

func (r *Registry) Load(dst interface{})

func (*Registry) LoadType

func (r *Registry) LoadType(typ reflect.Type) (val interface{})

LoadType returns a value for the specified type typ

func (*Registry) LoadValue

func (r *Registry) LoadValue(dst reflect.Value)

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) MapProvider

func (r *Registry) MapProvider(typ reflect.Type, provider Provider)

func (*Registry) MustDispose

func (r *Registry) MustDispose()

MustDispose works same as End, 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

func (r *Registry) WithTypeAndValue(typOf reflect.Type, value interface{})

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

Jump to

Keyboard shortcuts

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