arg

package
v0.0.0-...-bd77e7c Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package arg provide a method arguments binding。

Package arg is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Option

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

Option returning parameter binding for the Option function.

Types

type Arg

type Arg interface{}

Arg is used to provide binding values for function parameters. It can be of type bean.Selector, indicating injection of a bean. It can be a string in the form of ${X:=Y}, representing property binding or injection of a bean. It can be of type ValueArg, representing a regular value passed by the user instead of being retrieved from the IoC container. It can be of type IndexArg, representing parameter binding with an index. It can be of type *optionArg, used to provide parameter binding for the Option method.

type Callable

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

Callable wrappers a function and its binding arguments, then you can invoke the Call method of Callable to get the function's result.

func Bind

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

Bind returns a Callable that wrappers a function and its binding arguments. The argument skip is the number of frames to skip over.

func Provide

func Provide(fn interface{}, args ...Arg) *Callable

Provide binding runtime parameters for the Option method.

func (*Callable) Arg

func (r *Callable) Arg(i int) (Arg, bool)

Arg returns the ith binding argument.

func (*Callable) Call

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

Call invokes the function with its binding arguments processed in the IoC container. If the function returns an error, then the Call returns it.

func (*Callable) In

func (r *Callable) In(i int) (reflect.Type, bool)

type Context

type Context interface {
	// Matches returns true when the Condition returns true,
	// and returns false when the Condition returns false.
	Matches(c cond.Condition) (bool, error)
	// Bind binds properties value by the "value" tag.
	Bind(v reflect.Value, tag string) error
	// Wire wires dependent beans by the "autowire" tag.
	Wire(v reflect.Value, tag string) error
}

Context defines some methods of IoC container that Callable use.

type IndexArg

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

IndexArg is an Arg that has an index.

func Index

func Index(n int, arg Arg) IndexArg

Index returns an IndexArg.

func R0

func R0(arg Arg) IndexArg

R0 returns an IndexArg with index 0.

func R1

func R1(arg Arg) IndexArg

R1 returns an IndexArg with index 1.

func R2

func R2(arg Arg) IndexArg

R2 returns an IndexArg with index 2.

func R3

func R3(arg Arg) IndexArg

R3 returns an IndexArg with index 3.

func R4

func R4(arg Arg) IndexArg

R4 returns an IndexArg with index 4.

func R5

func R5(arg Arg) IndexArg

R5 returns an IndexArg with index 5.

func R6

func R6(arg Arg) IndexArg

R6 returns an IndexArg with index 6.

type MockArg

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

MockArg is a mock of Arg interface.

func NewMockArg

func NewMockArg(ctrl *gomock.Controller) *MockArg

NewMockArg creates a new mock instance.

func (*MockArg) EXPECT

func (m *MockArg) EXPECT() *MockArgMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

type MockArgMockRecorder

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

MockArgMockRecorder is the mock recorder for MockArg.

type MockContext

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

MockContext is a mock of Context interface.

func NewMockContext

func NewMockContext(ctrl *gomock.Controller) *MockContext

NewMockContext creates a new mock instance.

func (*MockContext) Bind

func (m *MockContext) Bind(v reflect.Value, tag string) error

Bind mocks base method.

func (*MockContext) EXPECT

func (m *MockContext) EXPECT() *MockContextMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockContext) Matches

func (m *MockContext) Matches(c cond.Condition) (bool, error)

Matches mocks base method.

func (*MockContext) Wire

func (m *MockContext) Wire(v reflect.Value, tag string) error

Wire mocks base method.

type MockContextMockRecorder

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

MockContextMockRecorder is the mock recorder for MockContext.

func (*MockContextMockRecorder) Bind

func (mr *MockContextMockRecorder) Bind(v, tag interface{}) *gomock.Call

Bind indicates an expected call of Bind.

func (*MockContextMockRecorder) Matches

func (mr *MockContextMockRecorder) Matches(c interface{}) *gomock.Call

Matches indicates an expected call of Matches.

func (*MockContextMockRecorder) Wire

func (mr *MockContextMockRecorder) Wire(v, tag interface{}) *gomock.Call

Wire indicates an expected call of Wire.

type ValueArg

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

ValueArg is an Arg that has a value.

func Nil

func Nil() ValueArg

Nil return a ValueArg with a value of nil.

func Value

func Value(v interface{}) ValueArg

Value return a ValueArg with a value of v.

Jump to

Keyboard shortcuts

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