Documentation
¶
Index ¶
- func Record(v interface{}, pre interface{}, post interface{}) func()
- func RecordCall(v interface{}, pre interface{}) func()
- func RecordResult(v interface{}, post interface{}) func()
- func Trace(config Config, request interface{}, fn func() (interface{}, error)) (response interface{}, err error)
- type Config
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Record ¶ added in v1.1.0
func Record(v interface{}, pre interface{}, post interface{}) func()
Record setup a recorder for v, with pre-hook and post-hook
func RecordCall ¶ added in v1.1.0
func RecordCall(v interface{}, pre interface{}) func()
RecordCall is a convenience function for recording a call to a function with a pre-hook. a practical example would be:
func SetupLog(t *testing.T) {
trace.RecordCall(log.Errorf, func(ctx context.Context, format string, params []interface{}) {
t.Logf("ERROR "+format, params...)
})
}
func RecordResult ¶ added in v1.1.0
func RecordResult(v interface{}, post interface{}) func()
RecordResult is a convenience function for recording a result from a function
Types ¶
type Config ¶ added in v1.1.0
type Config struct {
// OnFinish is called when the trace is finished
OnFinish func(stack stack_model.IStack) `json:"-"`
// OutputFile specifies the file to save the trace
// in json format, which can be open by:
// xgo tool trace <OutputFile>
OutputFile string `json:"OutputFile,omitempty"`
// FilterTrace is called to filter the trace
FilterTrace func(funcInfo *core.FuncInfo) bool `json:"-"`
}
Click to show internal directories.
Click to hide internal directories.