feat(workflow): 恢复例程 + 心跳 + 启动/周期扫描

This commit is contained in:
2026-08-25 16:44:29 +08:00
parent 788c835580
commit 95dc0d6052
4 changed files with 256 additions and 3 deletions
@@ -12,6 +12,7 @@ import (
"gitea.redpowerfuture.com/red-future/common/beans"
_ "github.com/gogf/gf/contrib/drivers/pgsql/v2"
"github.com/gogf/gf/v2/net/gtrace"
)
// TestExecWorkflowRetryColsRoundTrip 验证三新列读写 + ListRecoverable 三类判定(需 AI_AGENT_TEST_DB=1 且本地 PG 可用)
@@ -19,8 +20,11 @@ func TestExecWorkflowRetryColsRoundTrip(t *testing.T) {
if !isTestDBEnabled(t) {
t.Skip("skip: AI_AGENT_TEST_DB not set")
}
// gfdb 的 Hook 依赖 ctx 中注入用户信息(租户/创建人),否则 Insert 报 "token 数据为空"
ctx := context.WithValue(context.Background(), "user", &beans.User{
// gfdb 的 Hook 依赖 ctx 中注入用户信息(租户/创建人),否则 Insert 报 "token 数据为空"
// 先造 spanListRecoverable 链 NoTenantId 依赖 traceID 作 gcache 标记键,无 span 时 getTraceID 返回空 → NoTenantId 返回 nil 会 panic
ctx, span := gtrace.NewSpan(context.Background(), "test.recover")
defer span.End()
ctx = context.WithValue(ctx, "user", &beans.User{
UserName: "test-retry", TenantId: 1,
})
id, err := ExecWorkflowDao.Insert(ctx, &sessionDto.CreateWorkflowReq{