fix: 修正轮询配置多匹配逻辑,支持同卡匹配多个配置并按 priority 合并 interval
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m27s

核心变更:
- MatchConfig 改为 MatchConfigs,返回所有匹配配置
- MergedTaskIntervals 按 task type 合并各配置,选取最高优先级(非 nil 且最小 priority 值)
- hasAnyEnabledInterval 过滤所有 interval 均为 NULL 的配置
- calcInitialDelay 重构为纯函数,接收 interval 参数
- 移除 getEnabledTaskTypes 和 getIntervalByTaskType(被 MergedTaskIntervals 替代)
- scheduler.go 新增心跳 key + 顶层 panic recovery + Init 完成守卫
- initializer.go 批量失败日志升级为 Error,逐条检查 Pipeline 命令错误
- 数据迁移:禁用 id=29 的轮询配置(所有 interval 均为 NULL)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-16 14:27:47 +08:00
parent 5065d925ad
commit 5d9be1d7e4
15 changed files with 770 additions and 231 deletions

View File

@@ -102,20 +102,18 @@ func (b *PollingBase) requeueCard(ctx context.Context, cardID uint, taskType str
return b.queueMgr.Requeue(ctx, cardID, taskType, time.Now().Add(30*time.Second))
}
cfg := b.configMgr.MatchConfig(card)
if cfg == nil {
// 兜底:配置未加载DB 暂时不可达)时延迟 30 秒重入队,防止卡从轮询永久消失
intervals := b.configMgr.MergedTaskIntervals(card)
if len(intervals) == 0 {
// 兜底:配置未加载时延迟 30 秒重入队,防止卡从轮询永久消失
b.logger.Warn("无匹配轮询配置30秒后重入队配置可能未加载",
zap.Uint("card_id", cardID), zap.String("task_type", taskType))
return b.queueMgr.Requeue(ctx, cardID, taskType, time.Now().Add(30*time.Second))
}
interval := getIntervalByTaskType(cfg, taskType)
if interval <= 0 {
info, ok := intervals[taskType]
if !ok || info.Interval <= 0 {
b.logger.Debug("轮询间隔为 NULL不入队", zap.Uint("card_id", cardID), zap.String("task_type", taskType))
return nil
}
nextCheckAt := time.Now().Add(time.Duration(interval) * time.Second)
nextCheckAt := time.Now().Add(time.Duration(info.Interval) * time.Second)
return b.queueMgr.Requeue(ctx, cardID, taskType, nextCheckAt)
}