feat: 停复机指令队列与设备维度判断
Some checks failed
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Has been cancelled
Some checks failed
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Has been cancelled
自动停复机统一经停复机指令队列执行(全局开关 polling.stop_resume.queue_enabled,默认关闭): - 统一判断函数 decideCard,新旧路径共用;暂停轮询的卡在套餐到期、退款场景照常停机 - 同卡一条指令、版本号覆盖;领取校验单卡最小重试间隔;先于卡任务领取,不受 scheduler_mode 限制 - 执行器只调用一次网关,按错误分类退避与告警,结果未知在队列内确认 - 设备维度判断合并请求与场景,版本变化再判断,旧路径持设备锁时推后 - 套餐激活、重置、订单、流量扣减、套餐到期、退款、实名管控修改改为请求评估 - 监控增加停复机队列与近 1 小时执行计数,单卡轮询状态返回当前指令 - 迁移 000255 插入开关与告警、退避参数 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -503,6 +503,28 @@ func (s *CarrierSchedulerService) CardState(ctx context.Context, cardID uint) (*
|
||||
}
|
||||
resp.Types = append(resp.Types, state)
|
||||
}
|
||||
resp.StopResumeQueueEnabled = s.settings.Current(ctx).StopResumeQueueEnabled
|
||||
command, err := s.store.ReadCommand(ctx, card.ID)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(errors.CodeRedisError, err, "读取卡停复机指令失败")
|
||||
}
|
||||
if !command.LastCallAt.IsZero() {
|
||||
resp.LastStopResumeCallAt = timePtr(command.LastCallAt)
|
||||
}
|
||||
if command.Exists {
|
||||
item := &dto.CardStopResumeCommandState{Action: command.Action, Reason: command.Reason, Scenes: command.Scenes, Source: command.Source,
|
||||
Version: command.Version, FailCount: command.FailCount, LastError: command.LastError, Pending: command.Pending, Unknown: command.Unknown}
|
||||
if item.Scenes == nil {
|
||||
item.Scenes = []string{}
|
||||
}
|
||||
if !command.WrittenAt.IsZero() {
|
||||
item.WrittenAt = timePtr(command.WrittenAt)
|
||||
}
|
||||
if !command.NextAt.IsZero() {
|
||||
item.NextAt = timePtr(command.NextAt)
|
||||
}
|
||||
resp.StopResumeCommand = item
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
@@ -571,6 +593,13 @@ func (s *CarrierSchedulerService) CarrierStats(ctx context.Context) (*dto.Carrie
|
||||
item.RateLimited += atoi64(values[constants.GatewayErrorRateLimited])
|
||||
}
|
||||
item.QPSLastMinute = float64(attempts) / 60
|
||||
if srStats, srErr := s.store.StopResumeStats(ctx, carrierID); srErr == nil {
|
||||
item.StopResumeQueueLength, item.StopResumeDue = srStats.Queued, srStats.Due
|
||||
item.StopResumeRunning, item.StopResumePending = srStats.Running, srStats.Pending
|
||||
}
|
||||
srCounts := s.store.StopResumeStatLastHour(ctx, carrierID)
|
||||
item.StopResumeSuccess1h, item.StopResumeFailed1h = srCounts[constants.StopResumeStatSuccess], srCounts[constants.StopResumeStatFailed]
|
||||
item.StopResumeRetry1h, item.StopResumeUnknown1h = srCounts[constants.StopResumeStatRetry], srCounts[constants.StopResumeStatUnknown]
|
||||
for _, alert := range alertRows {
|
||||
if alert.CarrierID == carrierID {
|
||||
item.OpenAlerts += alert.Count
|
||||
|
||||
Reference in New Issue
Block a user