- refactor jxcontent and tasksch (remove dependency from jxcontent to tasksch)

- send dingding msg to user when async task finished
This commit is contained in:
gazebo
2019-03-22 15:04:28 +08:00
parent 0f5445020a
commit 25ac631c5c
31 changed files with 1527 additions and 1488 deletions

View File

@@ -7,38 +7,41 @@ import (
"time"
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
)
func TestRunSeqTask(t *testing.T) {
var seqTask ITask
seqTask = NewSeqTask("TestSeqTask", "autotest", func(task *SeqTask, step int, params ...interface{}) (result interface{}, err error) {
switch step {
case 0:
fmt.Println("ONE")
task2 := NewParallelTask("hello", nil, "xjh", func(parallelTask *ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
i := batchItemList[0].(int)
time.Sleep(2 * time.Second)
fmt.Println(i * 2)
return nil, nil
}, []int{1, 2, 3})
seqTask.AddChild(task2)
time.Sleep(time.Duration(rand.Intn(3)) * time.Second)
task2.Run()
case 1:
fmt.Println("TWO")
time.Sleep(time.Duration(rand.Intn(3)) * time.Second)
case 2:
fmt.Println("THREE")
time.Sleep(time.Duration(rand.Intn(3)) * time.Second)
case 3:
fmt.Println("FOUR")
time.Sleep(time.Duration(rand.Intn(3)) * time.Second)
case 4:
fmt.Println("FIVE")
time.Sleep(time.Duration(rand.Intn(3)) * time.Second)
}
return []string{"1"}, nil
}, 5)
seqTask = NewSeqTask("TestSeqTask", jxcontext.AdminCtx,
func(task *SeqTask, step int, params ...interface{}) (result interface{}, err error) {
switch step {
case 0:
fmt.Println("ONE")
task2 := NewParallelTask("hello", nil, jxcontext.AdminCtx,
func(parallelTask *ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
i := batchItemList[0].(int)
time.Sleep(2 * time.Second)
fmt.Println(i * 2)
return nil, nil
}, []int{1, 2, 3})
seqTask.AddChild(task2)
time.Sleep(time.Duration(rand.Intn(3)) * time.Second)
task2.Run()
case 1:
fmt.Println("TWO")
time.Sleep(time.Duration(rand.Intn(3)) * time.Second)
case 2:
fmt.Println("THREE")
time.Sleep(time.Duration(rand.Intn(3)) * time.Second)
case 3:
fmt.Println("FOUR")
time.Sleep(time.Duration(rand.Intn(3)) * time.Second)
case 4:
fmt.Println("FIVE")
time.Sleep(time.Duration(rand.Intn(3)) * time.Second)
}
return []string{"1"}, nil
}, 5)
seqTask.Run()
time.Sleep(3 * time.Second)