Documentation ¶
Index ¶
- func BytesToInt32(buf []byte) int32
- func CallAsyncFuncAndWaitByFlag(flagPath, logPath string, funcAsync func() error, timeoutSeconds int) ([]string, error)
- func CallAsyncFuncAndWaitByLog(logPath string, funcAsync func() error, ...) error
- func If(condition bool, trueVal, falseVal interface{}) interface{}
- func IfByFunc(condition IfCondition, trueVal IfTrueVal, falseVal IfFalseVal) (interface{}, error)
- func IfByFuncNoErr(condition IfCondition, trueVal IfTrueValNoError, falseVal IfFalseValNoError) interface{}
- func Int32ToBytes(i int32) []byte
- func PrintStack(msg string)
- type IfCondition
- type IfFalseVal
- type IfFalseValNoError
- type IfTrueVal
- type IfTrueValNoError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CallAsyncFuncAndWaitByFlag ¶ added in v0.0.9
func CallAsyncFuncAndWaitByLog ¶ added in v0.0.9
func CallAsyncFuncAndWaitByLog(logPath string, funcAsync func() error, funcHandlerLogLine func(line string) (bool, error), timeoutSeconds int) error
CallAsyncFuncAndWaitByLog 调用异步函数并根据日志处理函数等待结束
- logPath 用于监听异步函数是否执行结束的日志文件,会在调用异步函数funcAsync之前删除
- funcAsync 异步函数,注意CallAsyncFuncAndWaitByLog内部会在删除日志文件后直接以同步方式调用该函数.即funcAsync的异步处理是由其内部完成的.
- funcHandlerLogLine 日志按行处理函数,该函数以一行日志为入参,根据该函数的返回值确定是否结束等待.返回bool为true时则结束等待,返回error非空时结束等待并返回该error.
- timeoutSeconds 等待的超时秒数,超过该时间则立即结束等待并返回超时错误.
该函数内部会先删除logPath文件,然后执行funcAsync,然后tail监听logPath文件,将获取到的每一行日志作为入参调用funcHandlerLogLine进行判断,根据结果决定是否继续tail.如果超时则直接返回超时错误.
func If ¶ added in v0.0.9
func If(condition bool, trueVal, falseVal interface{}) interface{}
If 判断条件是否为真,如果为真则返回第一个参数,否则返回第二个参数
func IfByFunc ¶ added in v0.0.9
func IfByFunc(condition IfCondition, trueVal IfTrueVal, falseVal IfFalseVal) (interface{}, error)
func IfByFuncNoErr ¶ added in v0.0.9
func IfByFuncNoErr(condition IfCondition, trueVal IfTrueValNoError, falseVal IfFalseValNoError) interface{}
Types ¶
type IfCondition ¶ added in v0.0.9
type IfCondition func() bool
type IfFalseVal ¶ added in v0.0.9
type IfFalseVal func() (interface{}, error)
type IfFalseValNoError ¶ added in v0.0.9
type IfFalseValNoError func() interface{}
type IfTrueValNoError ¶ added in v0.0.9
type IfTrueValNoError func() interface{}
Click to show internal directories.
Click to hide internal directories.