fix: 修复轮询系统缓存不一致和可观测性问题
Some checks failed
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Has been cancelled
Some checks failed
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Has been cancelled
- OnCardStatusChanged/Enabled/Disabled 添加 InvalidateCardCache, 解决 Refresh API 更新 DB 后 polling 缓存仍为旧值的 bug - AssetResolveResponse 的 enable_polling/network_status 去掉 omitempty,解决 false/0 时字段从响应中消失的问题 - Scheduler/Initializer/PackageHandler 增加 INFO 级别日志, 可通过日志判断轮询是否工作、处理了哪些卡
This commit is contained in:
@@ -129,6 +129,14 @@ func (m *PollingQueueManager) OnCardDeleted(ctx context.Context, cardID uint) er
|
||||
return m.redis.Del(ctx, cacheKey).Err()
|
||||
}
|
||||
|
||||
// InvalidateCardCache 清理轮询卡信息缓存,强制下次轮询从 DB 重建
|
||||
func (m *PollingQueueManager) InvalidateCardCache(ctx context.Context, cardID uint) {
|
||||
cacheKey := constants.RedisPollingCardInfoKey(cardID)
|
||||
if err := m.redis.Del(ctx, cacheKey).Err(); err != nil {
|
||||
m.logger.Warn("清理轮询卡缓存失败", zap.Uint("card_id", cardID), zap.Error(err))
|
||||
}
|
||||
}
|
||||
|
||||
// GetQueueDepth 获取分片队列深度(用于背压检测)
|
||||
func (m *PollingQueueManager) GetQueueDepth(ctx context.Context, shardID int, taskType string) (int64, error) {
|
||||
key := constants.RedisPollingShardQueueKey(shardID, taskType)
|
||||
|
||||
Reference in New Issue
Block a user