arg

package
v1.1.0-alpha Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package arg 用于实现函数参数绑定。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Option

func Option(fn interface{}, args ...Arg) *optionArg

Option 返回 Option 函数的参数绑定。

Types

type Arg

type Arg interface{}

Arg 用于为函数参数提供绑定值。可以是 bean.Selector 类型,表示注入 bean ; 可以是 ${X:=Y} 形式的字符串,表示属性绑定或者注入 bean ;可以是 ValueArg 类型,表示不从 IoC 容器获取而是用户传入的普通值;可以是 IndexArg 类型,表示 带有下标的参数绑定;可以是 *optionArg 类型,用于为 Option 方法提供参数绑定。

type Callable

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

Callable 绑定函数及其参数,然后通过 Call 方法获取绑定函数的执行结果。

func Bind

func Bind(fn interface{}, args []Arg, skip int) (*Callable, error)

Bind 绑定函数及其参数,skip 是相对于当前方法需要跳过的调用栈层数。

func (*Callable) Call

func (r *Callable) Call(ctx Context) ([]reflect.Value, error)

Call 通过反射机制获取函数的绑定参数并执行函数,最后返回函数的执行结果。

type Context

type Context interface {

	// Matches 条件成立返回 true,否则返回 false。
	Matches(c cond.Condition) (bool, error)

	// Bind 根据 tag 的内容对 v 进行属性绑定。
	Bind(v reflect.Value, tag string) error

	// Wire 根据 tag 的内容对 v 进行依赖注入。
	Wire(v reflect.Value, tag string) error
}

Context IoC 容器对 arg 模块提供的最小功能集。

type IndexArg

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

IndexArg 包含下标的参数绑定。

func Index

func Index(n int, arg Arg) IndexArg

Index 返回包含下标的参数绑定,下标从 1 开始。

func R0

func R0(arg Arg) IndexArg

R0 返回下标为 0 的参数绑定。

func R1

func R1(arg Arg) IndexArg

R1 返回下标为 1 的参数绑定。

func R2

func R2(arg Arg) IndexArg

R2 返回下标为 2 的参数绑定。

func R3

func R3(arg Arg) IndexArg

R3 返回下标为 3 的参数绑定。

func R4

func R4(arg Arg) IndexArg

R4 返回下标为 4 的参数绑定。

func R5

func R5(arg Arg) IndexArg

R5 返回下标为 5 的参数绑定。

func R6

func R6(arg Arg) IndexArg

R6 返回下标为 6 的参数绑定。

type ValueArg

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

ValueArg 包含具体值的参数绑定。

func Value

func Value(v interface{}) ValueArg

Value 返回包含具体值的参数绑定。

Jump to

Keyboard shortcuts

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