修复套餐接续停机竞态与轮询兜底
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 11m13s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 11m13s
This commit is contained in:
@@ -98,6 +98,20 @@ func (m *PollingQueueManager) Requeue(ctx context.Context, cardID uint, taskType
|
||||
}).Err()
|
||||
}
|
||||
|
||||
// EnsureQueued 仅在任务当前不在分片队列中时补入任务,不覆盖已有任务的执行时间。
|
||||
func (m *PollingQueueManager) EnsureQueued(ctx context.Context, cardID uint, taskType string, nextCheckAt time.Time) (bool, error) {
|
||||
shardID := int(cardID) % m.shardCount
|
||||
key := constants.RedisPollingShardQueueKey(shardID, taskType)
|
||||
added, err := m.redis.ZAddArgs(ctx, key, redis.ZAddArgs{
|
||||
NX: true,
|
||||
Members: []redis.Z{{
|
||||
Score: float64(nextCheckAt.Unix()),
|
||||
Member: fmt.Sprintf("%d", cardID),
|
||||
}},
|
||||
}).Result()
|
||||
return added > 0, err
|
||||
}
|
||||
|
||||
// RemoveFromAllQueues 从所有分片的所有5个队列(realname/carddata/package/protect/card_status)移除指定卡
|
||||
// 修复 Bug3:旧实现漏掉 protect 队列
|
||||
func (m *PollingQueueManager) RemoveFromAllQueues(ctx context.Context, cardID uint) error {
|
||||
|
||||
Reference in New Issue
Block a user