+ xiang.flow.Sleep

This commit is contained in:
Max 2022-02-16 14:57:52 +08:00
parent e21f93af45
commit 47ccd31e69

View file

@ -1,6 +1,8 @@
package helper
import (
"time"
"github.com/yaoapp/gou"
"github.com/yaoapp/kun/utils"
)
@ -60,6 +62,8 @@ func init() {
gou.RegisterProcessHandler("xiang.helper.Print", ProcessPrint)
gou.AliasProcess("xiang.helper.Print", "xiang.sys.Print")
gou.RegisterProcessHandler("xiang.flow.Sleep", ProcessSleep)
}
// ProcessPrint xiang.helper.Print 打印语句
@ -68,3 +72,11 @@ func ProcessPrint(process *gou.Process) interface{} {
utils.Dump(process.Args...)
return nil
}
// ProcessSleep xiang.flow.Sleep 等待
func ProcessSleep(process *gou.Process) interface{} {
process.ValidateArgNums(1)
ms := process.ArgsInt(0)
time.Sleep(time.Duration((ms * int(time.Millisecond))))
return nil
}