di

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2022 License: MIT Imports: 4 Imported by: 3

Documentation

Overview

Package di provides a reflection based dependency injection toolkit.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CleanUp

type CleanUp func() error

CleanUp represents a clean up function.

func (CleanUp) Do

func (a CleanUp) Do() (err error)

Do does the clean up.

type Closer added in v0.0.2

type Closer interface {
	Close() error
}

Closer is the interface that wraps the basic Close method.

type Injector

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

Injector represents a dependency injector.

func New

func New(parent *Injector) *Injector

New creates a new injector.

func (*Injector) Close added in v0.0.2

func (a *Injector) Close() (err error)

Close frees up resources allocated for the injector.

func (*Injector) Invoke

func (a *Injector) Invoke(function interface{}) (result Result, err error)

Invoke runs the given function after instantiating its dependencies.

func (*Injector) MustProvide

func (a *Injector) MustProvide(constructor interface{}, itype interface{}, singleton bool)

MustProvide is like Provide but panics if has error.

func (*Injector) Provide

func (a *Injector) Provide(constructor interface{}, itype interface{}, singleton bool) error

Provide teaches the injector how to build values and expresses their dependencies.

type Result

type Result []reflect.Value

Result represents a invoke result.

func (Result) Scan

func (a Result) Scan(vs ...interface{}) (err error)

Scan copies the result into the values pointed at by vs.

Jump to

Keyboard shortcuts

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