feat(config): add retry and waitcapture property

This commit is contained in:
eson
2020-11-25 16:34:15 +08:00
parent 899f554336
commit b14615f339
7 changed files with 54 additions and 28 deletions

View File

@@ -4,6 +4,7 @@ import (
"fmt"
"log"
"net/http"
"strconv"
"time"
"github.com/bwmarrin/snowflake"
@@ -85,6 +86,18 @@ func PutTask(c *gin.Context) {
data.Store("label", label)
data.Store("content_condition", c.PostForm("content_condition"))
if waitcapture, err := strconv.Atoi(c.PostForm("waitcapture")); err != nil {
data.Store("waitcapture", 1)
} else {
data.Store("waitcapture", waitcapture)
}
if retry, err := strconv.Atoi(c.PostForm("retry")); err != nil {
data.Store("retry", 1)
} else {
data.Store("retry", retry)
}
taskQueue.Push(tid, data)
oplog.Write(data)
c.JSON(http.StatusOK, Response{Code: 200, Message: "ok", Data: data})
@@ -110,7 +123,6 @@ func ContentTask(c *gin.Context) {
task.Store("status", "ready")
readyQueue.Push(tid, task) // 进入回调发送队列.TODO: 内容持久化
c.JSON(200, Response{Code: 200, Data: task})
// log.Println("start callback")
if label, ok := task.Load("label"); ok {
log.Println(label.(string), tid)
}