Documentation
¶
Index ¶
- Constants
- Variables
- func AddInterceptor(interceptor *Interceptor) func()
- func ClearLocalInterceptors()
- func Direct(fn func())
- func GetTrappingPC() uintptr
- func Inspect(f interface{}) (recvPtr interface{}, funcInfo *core.FuncInfo)
- func InspectPC(f interface{}) (recvPtr interface{}, funcInfo *core.FuncInfo, funcPC uintptr, ...)
- func Skip()
- func WithInterceptor(interceptor *Interceptor, f func())
- type Interceptor
Constants ¶
const ClosureHasFunc = true
const GenericImplIsClosure = false
Variables ¶
var ErrAbort error = errors.New("abort trap interceptor")
Functions ¶
func AddInterceptor ¶
func AddInterceptor(interceptor *Interceptor) func()
func ClearLocalInterceptors ¶
func ClearLocalInterceptors()
func Direct ¶ added in v1.0.16
func Direct(fn func())
Direct make a call to fn, without any trap and mock interceptors
func GetTrappingPC ¶ added in v1.0.10
func GetTrappingPC() uintptr
func Inspect ¶ added in v1.0.8
Inspect make a call to f to capture its receiver pointer if it is bound method It can be used to get the unwrapped innermost function of a method wrapper. if f is a bound method, then guaranteed that recvPtr cannot be nil
func Skip ¶
func Skip()
Skip serves as mark to tell xgo not insert trap instructions for the function that calls Skip() NOTE: the function body is intenionally leave empty as trap.Skip() is just a mark that makes sense at compile time.
func WithInterceptor ¶
func WithInterceptor(interceptor *Interceptor, f func())
WithInterceptor executes given f with interceptor setup. It can be used from init phase safely. it clears the interceptor after f finishes. the interceptor will be added to head, so it will gets firstly invoked. f cannot be nil.
NOTE: the implementation uses addLocalInterceptor even from init because it will be soon cleared without causing concurrent issues.
Types ¶
type Interceptor ¶
type Interceptor struct {
Pre func(ctx context.Context, f *core.FuncInfo, args core.Object, result core.Object) (data interface{}, err error)
Post func(ctx context.Context, f *core.FuncInfo, args core.Object, result core.Object, data interface{}) error
}
func GetAllInterceptors ¶
func GetAllInterceptors() []*Interceptor
func GetInterceptors ¶
func GetInterceptors() []*Interceptor
func GetLocalInterceptors ¶
func GetLocalInterceptors() []*Interceptor