发布 0.2.0:模型池自愈、探测修正、任务异步触发与删除加固
CI / test (push) Successful in 32s
Release / release (push) Successful in 52s

This commit is contained in:
2026-07-10 20:25:37 +08:00
parent dbba1f4905
commit 7706f59549
19 changed files with 978 additions and 107 deletions
+10 -5
View File
@@ -2,6 +2,7 @@ package api
import (
"encoding/json"
"errors"
"net/http"
"strconv"
@@ -155,10 +156,11 @@ func (h *taskHandler) logs(c *gin.Context) {
c.JSON(http.StatusOK, logs)
}
// @Summary 立即执行任务
// @Summary 立即执行任务(异步触发,结果经任务日志轮询获取)
// @Tags 任务与日志回传
// @Param id path int true "配置 ID"
// @Success 200 {object} map[string]any
// @Success 202 {object} map[string]any
// @Failure 409 {object} map[string]any "任务正在执行中"
// @Security BearerAuth
// @Router /api/v1/tasks/{id}/run [post]
func (h *taskHandler) run(c *gin.Context) {
@@ -166,10 +168,13 @@ func (h *taskHandler) run(c *gin.Context) {
if !ok {
return
}
entry, err := h.svc.RunTaskNow(c.Request.Context(), id)
if err != nil {
if err := h.svc.TriggerTask(c.Request.Context(), id); err != nil {
if errors.Is(err, service.ErrTaskRunning) {
c.JSON(http.StatusConflict, gin.H{"error": err.Error()})
return
}
respondError(c, err)
return
}
c.JSON(http.StatusOK, entry)
c.JSON(http.StatusAccepted, gin.H{"triggered": true})
}