Ai
0 Star 1 Fork 0

shallot/Go开发工具集

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
loop_main.go 698 Bytes
一键复制 编辑 原始数据 按行查看 历史
shallot 提交于 2024-08-22 14:58 +08:00 . 移入autohttp库。
package autohttp
import (
"context"
"time"
)
func init() {
go loopMain()
}
// 主循环,用于重试HTTP请求
func loopMain() {
ctx := context.Background()
for {
// 间隔
time.Sleep(time.Duration(LoopInterval) * time.Second)
// 校验数据库回调
if DatabaseCallback == nil {
continue
}
// 查询未完成任务
now := time.Now().Unix()
taskList, e := DatabaseCallback.IncompleteTaskIdList(ctx, now)
if e != nil {
continue
}
// 对未完成任务,查询详情并发起重试
for _, taskId := range taskList {
taskItem, ee := DatabaseCallback.TaskDetail(ctx, taskId)
if ee != nil {
continue
}
_, _, _ = apiBase(ctx, &taskItem)
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/gxsshallot/gotool.git
git@gitee.com:gxsshallot/gotool.git
gxsshallot
gotool
Go开发工具集
d05a69787598

搜索帮助