- 迁移 000251~000254:运营商账户调度参数、请求检查场景(预置 8 个)、卡轮询失败告警表,以及调度模式、步骤、退避、告警等受控系统配置(默认 legacy,行为不变);并发配置表注释标记废弃 - 受控系统配置注册与 JSON 结构校验:步骤只能是 4 种检查类型且不重复、退避序列递增 - yaml 增加 NSQ 地址、msg_timeout、租约、续期间隔、分发间隔、默认执行上限与 max_in_flight;引入 go-nsq - 测试环境 docker-compose 增加 nsqlookupd 与 nsqd,Worker 注入 NSQ 地址 - 账户队列 Redis 结构与 Lua:领取(执行上限、优先占比、按限流组剩余 QPS 估算)、抢执行权、续期、收尾、请求检查(合并、冷却、执行中打优先标记)、移出、发布失败释放
77 lines
4.6 KiB
Go
77 lines
4.6 KiB
Go
package model
|
|
|
|
import (
|
|
"time"
|
|
|
|
"gorm.io/datatypes"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
// CarrierPollingParam 运营商账户调度参数;未配置的账户没有记录,使用全局默认。
|
|
type CarrierPollingParam struct {
|
|
ID uint `gorm:"column:id;primaryKey" json:"id"`
|
|
CarrierID uint `gorm:"column:carrier_id;not null" json:"carrier_id"`
|
|
InflightLimit *int `gorm:"column:inflight_limit" json:"inflight_limit"`
|
|
CardMaxInFlight *int `gorm:"column:card_max_in_flight" json:"card_max_in_flight"`
|
|
StopResumeMaxInFlight *int `gorm:"column:stop_resume_max_in_flight" json:"stop_resume_max_in_flight"`
|
|
SRInflightLimit *int `gorm:"column:sr_inflight_limit" json:"sr_inflight_limit"`
|
|
PriorityMaxRatio *float64 `gorm:"column:priority_max_ratio" json:"priority_max_ratio"`
|
|
StopResumeMinInterval *int `gorm:"column:stop_resume_min_interval" json:"stop_resume_min_interval"`
|
|
StopResumeConfirmDelay *int `gorm:"column:stop_resume_confirm_delay" json:"stop_resume_confirm_delay"`
|
|
Creator uint `gorm:"column:creator;not null;default:0" json:"creator"`
|
|
Updater uint `gorm:"column:updater;not null;default:0" json:"updater"`
|
|
CreatedAt time.Time `gorm:"column:created_at" json:"created_at"`
|
|
UpdatedAt time.Time `gorm:"column:updated_at" json:"updated_at"`
|
|
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;index" json:"-"`
|
|
}
|
|
|
|
// TableName 返回运营商账户调度参数表名。
|
|
func (CarrierPollingParam) TableName() string {
|
|
return "tb_carrier_polling_param"
|
|
}
|
|
|
|
// PollingCheckScene 业务事件与读入口请求检查场景;场景由代码预置,后台只可修改检查类型、确认延迟与冷却。
|
|
type PollingCheckScene struct {
|
|
ID uint `gorm:"column:id;primaryKey" json:"id"`
|
|
Scene string `gorm:"column:scene;type:varchar(50);not null" json:"scene"`
|
|
SceneName string `gorm:"column:scene_name;type:varchar(100);not null" json:"scene_name"`
|
|
CheckTypes datatypes.JSON `gorm:"column:check_types;type:jsonb;not null" json:"check_types"`
|
|
ConfirmDelays datatypes.JSON `gorm:"column:confirm_delays;type:jsonb;not null" json:"confirm_delays"`
|
|
Cooldown *int `gorm:"column:cooldown" json:"cooldown"`
|
|
Updater uint `gorm:"column:updater;not null;default:0" json:"updater"`
|
|
CreatedAt time.Time `gorm:"column:created_at" json:"created_at"`
|
|
UpdatedAt time.Time `gorm:"column:updated_at" json:"updated_at"`
|
|
}
|
|
|
|
// TableName 返回请求检查场景表名。
|
|
func (PollingCheckScene) TableName() string {
|
|
return "tb_polling_check_scene"
|
|
}
|
|
|
|
// PollingFailureAlert 卡轮询失败告警;同一卡同一检查类型只保留一条未处理告警。
|
|
type PollingFailureAlert struct {
|
|
ID uint `gorm:"column:id;primaryKey" json:"id"`
|
|
AlertLevel string `gorm:"column:alert_level;type:varchar(20);not null;default:card" json:"alert_level"`
|
|
CardID uint `gorm:"column:card_id;not null;default:0" json:"card_id"`
|
|
ICCID string `gorm:"column:iccid;type:varchar(30);not null;default:''" json:"iccid"`
|
|
CarrierID uint `gorm:"column:carrier_id;not null;default:0" json:"carrier_id"`
|
|
CheckType string `gorm:"column:check_type;type:varchar(30);not null" json:"check_type"`
|
|
ErrorCategory string `gorm:"column:error_category;type:varchar(50);not null;default:''" json:"error_category"`
|
|
FailCount int `gorm:"column:fail_count;not null;default:0" json:"fail_count"`
|
|
FirstFailedAt *time.Time `gorm:"column:first_failed_at" json:"first_failed_at"`
|
|
LastFailedAt *time.Time `gorm:"column:last_failed_at" json:"last_failed_at"`
|
|
LastError string `gorm:"column:last_error;type:varchar(500);not null;default:''" json:"last_error"`
|
|
Status int `gorm:"column:status;type:smallint;not null;default:1" json:"status"`
|
|
HandledBy uint `gorm:"column:handled_by;not null;default:0" json:"handled_by"`
|
|
HandledAt *time.Time `gorm:"column:handled_at" json:"handled_at"`
|
|
HandleRemark string `gorm:"column:handle_remark;type:varchar(500);not null;default:''" json:"handle_remark"`
|
|
RecoveredAt *time.Time `gorm:"column:recovered_at" json:"recovered_at"`
|
|
CreatedAt time.Time `gorm:"column:created_at" json:"created_at"`
|
|
UpdatedAt time.Time `gorm:"column:updated_at" json:"updated_at"`
|
|
}
|
|
|
|
// TableName 返回卡轮询失败告警表名。
|
|
func (PollingFailureAlert) TableName() string {
|
|
return "tb_polling_failure_alert"
|
|
}
|