All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 6m35s
实现功能: - 实名状态检查轮询(可配置间隔) - 卡流量检查轮询(支持跨月流量追踪) - 套餐检查与超额自动停机 - 分布式并发控制(Redis 信号量) - 手动触发轮询(单卡/批量/条件筛选) - 数据清理配置与执行 - 告警规则与历史记录 - 实时监控统计(队列/性能/并发) 性能优化: - Redis 缓存卡信息,减少 DB 查询 - Pipeline 批量写入 Redis - 异步流量记录写入 - 渐进式初始化(10万卡/批) 压测工具(scripts/benchmark/): - Mock Gateway 模拟上游服务 - 测试卡生成器 - 配置初始化脚本 - 实时监控脚本 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
85 lines
4.9 KiB
Go
85 lines
4.9 KiB
Go
package dto
|
||
|
||
import "time"
|
||
|
||
// CreatePollingAlertRuleReq 创建告警规则请求
|
||
type CreatePollingAlertRuleReq struct {
|
||
RuleName string `json:"rule_name" validate:"required,max=100" description:"规则名称"`
|
||
TaskType string `json:"task_type" validate:"required" description:"任务类型 (polling:realname/polling:carddata/polling:package)"`
|
||
MetricType string `json:"metric_type" validate:"required" description:"指标类型 (queue_size/success_rate/avg_duration/concurrency)"`
|
||
Operator string `json:"operator" validate:"omitempty,oneof=> >= < <= ==" description:"比较运算符,默认 >"`
|
||
Threshold float64 `json:"threshold" validate:"required" description:"阈值"`
|
||
AlertLevel string `json:"alert_level" validate:"required,oneof=warning critical" description:"告警级别 (warning/critical)"`
|
||
CooldownMinutes int `json:"cooldown_minutes" validate:"omitempty,min=0,max=1440" description:"冷却时间(分钟),默认5分钟"`
|
||
NotifyChannels string `json:"notify_channels" validate:"omitempty" description:"通知渠道(JSON格式)"`
|
||
}
|
||
|
||
// UpdatePollingAlertRuleReq 更新告警规则请求(Body 部分)
|
||
type UpdatePollingAlertRuleReq struct {
|
||
RuleName *string `json:"rule_name" validate:"omitempty,max=100" description:"规则名称"`
|
||
Threshold *float64 `json:"threshold" validate:"omitempty" description:"阈值"`
|
||
AlertLevel *string `json:"alert_level" validate:"omitempty,oneof=warning critical" description:"告警级别"`
|
||
Status *int `json:"status" validate:"omitempty,oneof=0 1" description:"状态 (0:禁用, 1:启用)"`
|
||
CooldownMinutes *int `json:"cooldown_minutes" validate:"omitempty,min=0,max=1440" description:"冷却时间(分钟)"`
|
||
NotifyChannels *string `json:"notify_channels" validate:"omitempty" description:"通知渠道"`
|
||
}
|
||
|
||
// UpdatePollingAlertRuleParams 更新告警规则参数(包含路径参数和 Body)
|
||
type UpdatePollingAlertRuleParams struct {
|
||
IDReq
|
||
UpdatePollingAlertRuleReq
|
||
}
|
||
|
||
// PollingAlertRuleResp 告警规则响应
|
||
type PollingAlertRuleResp struct {
|
||
ID uint `json:"id" description:"规则ID"`
|
||
RuleName string `json:"rule_name" description:"规则名称"`
|
||
TaskType string `json:"task_type" description:"任务类型"`
|
||
TaskTypeName string `json:"task_type_name" description:"任务类型名称"`
|
||
MetricType string `json:"metric_type" description:"指标类型"`
|
||
MetricTypeName string `json:"metric_type_name" description:"指标类型名称"`
|
||
Operator string `json:"operator" description:"比较运算符"`
|
||
Threshold float64 `json:"threshold" description:"阈值"`
|
||
AlertLevel string `json:"alert_level" description:"告警级别"`
|
||
Status int `json:"status" description:"状态 (0:禁用, 1:启用)"`
|
||
CooldownMinutes int `json:"cooldown_minutes" description:"冷却时间(分钟)"`
|
||
NotifyChannels string `json:"notify_channels" description:"通知渠道"`
|
||
CreatedAt time.Time `json:"created_at" description:"创建时间"`
|
||
UpdatedAt time.Time `json:"updated_at" description:"更新时间"`
|
||
}
|
||
|
||
// PollingAlertRuleListResp 告警规则列表响应
|
||
type PollingAlertRuleListResp struct {
|
||
Items []*PollingAlertRuleResp `json:"items" description:"告警规则列表"`
|
||
}
|
||
|
||
// PollingAlertHistoryResp 告警历史响应
|
||
type PollingAlertHistoryResp struct {
|
||
ID uint `json:"id" description:"历史ID"`
|
||
RuleID uint `json:"rule_id" description:"规则ID"`
|
||
RuleName string `json:"rule_name" description:"规则名称"`
|
||
TaskType string `json:"task_type" description:"任务类型"`
|
||
MetricType string `json:"metric_type" description:"指标类型"`
|
||
AlertLevel string `json:"alert_level" description:"告警级别"`
|
||
Threshold float64 `json:"threshold" description:"阈值"`
|
||
CurrentValue float64 `json:"current_value" description:"触发时的值"`
|
||
Message string `json:"message" description:"告警消息"`
|
||
CreatedAt time.Time `json:"created_at" description:"触发时间"`
|
||
}
|
||
|
||
// PollingAlertHistoryListResp 告警历史列表响应
|
||
type PollingAlertHistoryListResp struct {
|
||
Items []*PollingAlertHistoryResp `json:"items" description:"告警历史列表"`
|
||
Total int64 `json:"total" description:"总数"`
|
||
Page int `json:"page" description:"当前页"`
|
||
PageSize int `json:"page_size" description:"每页数量"`
|
||
TotalPages int `json:"total_pages" description:"总页数"`
|
||
}
|
||
|
||
// ListPollingAlertHistoryReq 查询告警历史请求
|
||
type ListPollingAlertHistoryReq struct {
|
||
RuleID *uint `json:"rule_id" query:"rule_id" description:"规则ID"`
|
||
Page int `json:"page" query:"page" validate:"omitempty,min=1" description:"页码"`
|
||
PageSize int `json:"page_size" query:"page_size" validate:"omitempty,min=1,max=100" description:"每页数量"`
|
||
}
|