XinYeYouKu/app/jobs/test.go

25 lines
581 B
Go
Raw Normal View History

2024-06-07 18:24:56 +08:00
package jobs
import (
"fmt"
"time"
"github.com/qit-team/work"
)
func test(task work.Task) (work.TaskResult) {
time.Sleep(time.Millisecond * 5)
s, err := work.JsonEncode(task)
if err != nil {
//work.StateFailed 不会进行ack确认
//work.StateFailedWithAck 会进行actk确认
//return work.TaskResult{Id: task.Id, State: work.StateFailed}
return work.TaskResult{Id: task.Id, State: work.StateFailedWithAck}
} else {
//work.StateSucceed 会进行ack确认
fmt.Println("do task", s)
return work.TaskResult{Id: task.Id, State: work.StateSucceed}
}
}