service/vendor/github.com/xxl-job/xxl-job-executor-go/util.go

68 lines
1.0 KiB
Go
Raw Normal View History

2024-01-17 19:52:54 +08:00
package xxl
import (
"encoding/json"
"strconv"
)
// Int64ToStr int64 to str
func Int64ToStr(i int64) string {
return strconv.FormatInt(i, 10)
}
//执行任务回调
func returnCall(req *RunReq, code int64, msg string) []byte {
data := call{
&callElement{
LogID: req.LogID,
LogDateTim: req.LogDateTime,
ExecuteResult: &ExecuteResult{
Code: code,
Msg: msg,
},
HandleCode: int(code),
HandleMsg: msg,
},
}
str, _ := json.Marshal(data)
return str
}
//杀死任务返回
func returnKill(req *killReq, code int64) []byte {
msg := ""
if code != SuccessCode {
msg = "Task kill err"
}
data := res{
Code: code,
Msg: msg,
}
str, _ := json.Marshal(data)
return str
}
//忙碌返回
func returnIdleBeat(code int64) []byte {
msg := ""
if code != SuccessCode {
msg = "Task is busy"
}
data := res{
Code: code,
Msg: msg,
}
str, _ := json.Marshal(data)
return str
}
//通用返回
func returnGeneral() []byte {
data := &res{
Code: SuccessCode,
Msg: "",
}
str, _ := json.Marshal(data)
return str
}