container

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TagOptionNotRequired = "NR" // Not Required, 标注该字段在执行注入时, 如果没有找到对应的实例, 则忽略该字段
)

Variables

View Source
var (
	ErrorDependNotCompleted = errors.New("依赖尚未完成")
)

Functions

This section is empty.

Types

type Container

type Container interface {
	Provider
	Populater
	Invoker
	Get(plugin plugin.Plugin, name ...string) (interface{}, error) // 从容器中获取一个指定类型的实例
}

Container 容器, 用于依赖注入

func New

func New() Container

type InjectTag

type InjectTag map[string]string

InjectTag 注入的所有 tag

type Invoker added in v1.0.0

type Invoker interface {
	Invoke(fn interface{}) ([]reflect.Value, error) // 返回一个函数的调用参数列表
}

Invoker 调用器, 用于返回一个函数的调用参数列表

type Option

type Option func(*entity)

func WithName added in v1.0.0

func WithName(name string) Option

type Populater added in v1.0.0

type Populater interface {
	Populate() error                                        // 填充所有实例
	PopulateSingle(val plugin.Plugin, opts ...Option) error // 填充一个实例
}

Populater 填充器, 用于填充依赖注入的实例

type Provider added in v1.0.0

type Provider interface {
	ProvideFunc(val interface{}, opts ...Option) error // 提供一个构建函数
	Provide(val plugin.Plugin, opts ...Option) error   // 提供一个实例
}

Provider 提供器, 用于提供依赖注入的实例

Jump to

Keyboard shortcuts

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