Documentation ¶
Index ¶
- Variables
- type AroundFunc
- type AroundFuncMock
- type AroundMockMock
- type Arounder
- type ArounderMap
- type ArounderMock
- type ArounderMockMock
- type IAroundFunc
- type IAroundMock
- type IArounderMock
- type IIoc
- type IIocMock
- type IProxyContext
- type IProxyContextMock
- type IProxyMock
- type Ioc
- type IocMock
- type IocMockMock
- type IproxyImpl
- type Proxy
- type ProxyContext
- type ProxyContextMock
- type ProxyContextMockMock
- type ProxyMock
- type ProxyMockMock
Constants ¶
This section is empty.
Variables ¶
View Source
var (
MockFieldNameSuffixes = [...]string{"Func", "Handler"} // mock结构体字段名称后缀
)
Functions ¶
This section is empty.
Types ¶
type AroundFunc ¶ added in v0.5.0
func (AroundFunc) Around ¶ added in v0.5.0
func (around AroundFunc) Around(pctx ProxyContext, method reflect.Value, args []reflect.Value) []reflect.Value
type AroundFuncMock ¶ added in v0.5.0
type AroundFuncMock struct {
AroundFunc func(pctx ProxyContext, method reflect.Value, args []reflect.Value) []reflect.Value
}
func (*AroundFuncMock) Around ¶ added in v0.5.0
func (mockRecv *AroundFuncMock) Around(pctx ProxyContext, method reflect.Value, args []reflect.Value) []reflect.Value
type AroundMockMock ¶ added in v0.5.0
type AroundMockMock struct { AfterFunc func(pctx ProxyContext) BeforeFunc func(pctx ProxyContext) }
func (*AroundMockMock) After ¶ added in v0.5.0
func (mockRecv *AroundMockMock) After(pctx ProxyContext)
func (*AroundMockMock) Before ¶ added in v0.5.0
func (mockRecv *AroundMockMock) Before(pctx ProxyContext)
type ArounderMap ¶ added in v0.6.0
type ArounderMap map[ProxyContext]AroundFunc
func (ArounderMap) Merge ¶ added in v0.6.0
func (m ArounderMap) Merge(nm ArounderMap) (mr ArounderMap)
type ArounderMock ¶ added in v0.5.0
type ArounderMock struct {
AroundFunc func(pctx ProxyContext, method reflect.Value, args []reflect.Value) []reflect.Value
}
func (*ArounderMock) Around ¶ added in v0.5.0
func (mockRecv *ArounderMock) Around(pctx ProxyContext, method reflect.Value, args []reflect.Value) []reflect.Value
type ArounderMockMock ¶ added in v0.5.0
type ArounderMockMock struct {
AroundFunc func(pctx ProxyContext, method reflect.Value, args []reflect.Value) []reflect.Value
}
func (*ArounderMockMock) Around ¶ added in v0.5.0
func (mockRecv *ArounderMockMock) Around(pctx ProxyContext, method reflect.Value, args []reflect.Value) []reflect.Value
type IAroundFunc ¶ added in v0.5.0
type IAroundMock ¶ added in v0.5.0
type IAroundMock interface { After(pctx ProxyContext) Before(pctx ProxyContext) }
type IArounderMock ¶ added in v0.5.0
type IProxyContext ¶ added in v0.5.0
type IProxyContextMock ¶ added in v0.5.0
type IProxyMock ¶ added in v0.5.0
type IProxyMock interface {
Around(provider interface{}, mock interface{}, arounder Arounder) interface{}
}
type Ioc ¶
type Ioc struct {
// contains filtered or unexported fields
}
Ioc 控制反转,Inversion of Control
func (*Ioc) Inject ¶
Inject 注入依赖
遍历v的字段,找到字段类型,再根据字段类型找到provider,调用provider获得实例,再把实例值赋给该字段 provider需要在接口定义处注册,注册到一个统一管理的地方 如果provider需要参数,则根据参数类型继续找寻相应的provider,直至初始化完成
func (*Ioc) RegisterProvider ¶
RegisterProvider 注册provider
type IocMock ¶ added in v0.5.0
type IocMock struct { InjectFunc func(v interface{}) (err error) RegisterProviderFunc func(v interface{}) (err error) }
func (*IocMock) RegisterProvider ¶ added in v0.5.0
type IocMockMock ¶ added in v0.5.0
type IocMockMock struct { InjectFunc func(v interface{}) (err error) RegisterProviderFunc func(v interface{}) (err error) }
func (*IocMockMock) Inject ¶ added in v0.5.0
func (mockRecv *IocMockMock) Inject(v interface{}) (err error)
func (*IocMockMock) RegisterProvider ¶ added in v0.5.0
func (mockRecv *IocMockMock) RegisterProvider(v interface{}) (err error)
type IproxyImpl ¶ added in v0.5.0
type IproxyImpl interface {
Around(provider interface{}, mock interface{}, arounder Arounder) interface{}
}
type Proxy ¶ added in v0.5.0
type Proxy interface {
Around(provider interface{}, mock interface{}, arounder Arounder) interface{}
}
Proxy 在层间依赖调用时插入钩子调用,类似AOP
type ProxyContext ¶ added in v0.5.0
func (ProxyContext) LogShortf ¶ added in v0.5.0
func (pctx ProxyContext) LogShortf(format string, args ...interface{})
func (ProxyContext) Logf ¶ added in v0.5.0
func (pctx ProxyContext) Logf(format string, args ...interface{})
func (ProxyContext) String ¶ added in v0.5.0
func (pctx ProxyContext) String() string
type ProxyContextMock ¶ added in v0.5.0
type ProxyContextMock struct { LogShortfFunc func(format string, args ...interface{}) LogfFunc func(format string, args ...interface{}) StringFunc func() string }
func (*ProxyContextMock) LogShortf ¶ added in v0.5.0
func (mockRecv *ProxyContextMock) LogShortf(format string, args ...interface{})
func (*ProxyContextMock) Logf ¶ added in v0.5.0
func (mockRecv *ProxyContextMock) Logf(format string, args ...interface{})
func (*ProxyContextMock) String ¶ added in v0.5.0
func (mockRecv *ProxyContextMock) String() string
type ProxyContextMockMock ¶ added in v0.5.0
type ProxyContextMockMock struct { LogfFunc func(format string, args ...interface{}) StringFunc func() string }
func (*ProxyContextMockMock) Logf ¶ added in v0.5.0
func (mockRecv *ProxyContextMockMock) Logf(format string, args ...interface{})
func (*ProxyContextMockMock) String ¶ added in v0.5.0
func (mockRecv *ProxyContextMockMock) String() string
type ProxyMock ¶ added in v0.5.0
type ProxyMock struct {
AroundFunc func(provider interface{}, mock interface{}, arounder Arounder) interface{}
}
type ProxyMockMock ¶ added in v0.5.0
type ProxyMockMock struct {
AroundFunc func(provider interface{}, mock interface{}, arounder Arounder) interface{}
}
func (*ProxyMockMock) Around ¶ added in v0.5.0
func (mockRecv *ProxyMockMock) Around(provider interface{}, mock interface{}, arounder Arounder) interface{}
Click to show internal directories.
Click to hide internal directories.