fix: 关闭轮询的卡不再重新入队
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 9m32s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 9m32s
关闭轮询时会移出队列并清除卡缓存,但执行收尾重入队、卡状态检查补齐套餐任务、限流重入队 都不判断轮询开关,执行中途被关闭的卡会被放回队列并互相补齐,关闭轮询无法生效。 - 卡缓存写入 enable_polling,旧缓存缺字段时从库补读并回写 - 重入队、补齐缺失任务、限流重入队前判断轮询开关,已关闭则不入队
This commit is contained in:
@@ -87,6 +87,12 @@ func (b *PollingBase) requeueRateLimited(cardID uint, taskType string) error {
|
||||
delay = configured
|
||||
}
|
||||
}
|
||||
ctx, cancel := pollingFallbackContext()
|
||||
card, err := b.getCardWithCache(ctx, cardID)
|
||||
cancel()
|
||||
if err == nil && !card.EnablePolling {
|
||||
return nil
|
||||
}
|
||||
return b.requeueCardAt(cardID, taskType, time.Now().Add(delay))
|
||||
}
|
||||
|
||||
@@ -189,6 +195,10 @@ func (b *PollingBase) ensureMissingTask(ctx context.Context, cardID uint, taskTy
|
||||
return err
|
||||
}
|
||||
|
||||
if !card.EnablePolling {
|
||||
// 已关闭轮询的卡不补齐任务,否则卡状态与套餐任务会互相补回队列,关闭轮询无法生效。
|
||||
return nil
|
||||
}
|
||||
info, ok := b.configMgr.MergedTaskIntervals(card)[taskType]
|
||||
if !ok || info.Interval <= 0 {
|
||||
return nil
|
||||
@@ -231,6 +241,11 @@ func (b *PollingBase) pollingNextCheckAt(ctx context.Context, cardID uint, taskT
|
||||
zap.Uint("card_id", cardID), zap.String("task_type", taskType), zap.Error(err))
|
||||
return time.Now().Add(pollingRequeueFallbackInterval), true
|
||||
}
|
||||
if !card.EnablePolling {
|
||||
// 执行中途被关闭轮询的卡不再重入队(关闭时已移出队列并清除缓存,此处读到的是库中最新值)。
|
||||
b.logger.Info("卡已关闭轮询,不再重入队", zap.Uint("card_id", cardID), zap.String("task_type", taskType))
|
||||
return time.Time{}, false
|
||||
}
|
||||
intervals := b.configMgr.MergedTaskIntervals(card)
|
||||
if len(intervals) == 0 {
|
||||
// 兜底:配置未加载时延迟 30 秒重入队,防止卡从轮询永久消失
|
||||
|
||||
Reference in New Issue
Block a user