Files
junhong_cmp_fiber/internal/routes/polling_alert.go
huang 931e140e8e
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 6m35s
feat: 实现 IoT 卡轮询系统(支持千万级卡规模)
实现功能:
- 实名状态检查轮询(可配置间隔)
- 卡流量检查轮询(支持跨月流量追踪)
- 套餐检查与超额自动停机
- 分布式并发控制(Redis 信号量)
- 手动触发轮询(单卡/批量/条件筛选)
- 数据清理配置与执行
- 告警规则与历史记录
- 实时监控统计(队列/性能/并发)

性能优化:
- Redis 缓存卡信息,减少 DB 查询
- Pipeline 批量写入 Redis
- 异步流量记录写入
- 渐进式初始化(10万卡/批)

压测工具(scripts/benchmark/):
- Mock Gateway 模拟上游服务
- 测试卡生成器
- 配置初始化脚本
- 实时监控脚本

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 17:32:44 +08:00

67 lines
2.1 KiB
Go

package routes
import (
"github.com/gofiber/fiber/v2"
"github.com/break/junhong_cmp_fiber/internal/handler/admin"
"github.com/break/junhong_cmp_fiber/internal/model/dto"
"github.com/break/junhong_cmp_fiber/pkg/openapi"
)
// registerPollingAlertRoutes 注册轮询告警路由
func registerPollingAlertRoutes(router fiber.Router, handler *admin.PollingAlertHandler, doc *openapi.Generator, basePath string) {
// 告警规则管理
rules := router.Group("/polling-alert-rules")
rulesPath := basePath + "/polling-alert-rules"
Register(rules, doc, rulesPath, "POST", "", handler.CreateRule, RouteSpec{
Summary: "创建轮询告警规则",
Tags: []string{"轮询管理-告警"},
Input: new(dto.CreatePollingAlertRuleReq),
Output: new(dto.PollingAlertRuleResp),
Auth: true,
})
Register(rules, doc, rulesPath, "GET", "", handler.ListRules, RouteSpec{
Summary: "获取轮询告警规则列表",
Tags: []string{"轮询管理-告警"},
Input: nil,
Output: new(dto.PollingAlertRuleListResp),
Auth: true,
})
Register(rules, doc, rulesPath, "GET", "/:id", handler.GetRule, RouteSpec{
Summary: "获取轮询告警规则详情",
Tags: []string{"轮询管理-告警"},
Input: new(dto.IDReq),
Output: new(dto.PollingAlertRuleResp),
Auth: true,
})
Register(rules, doc, rulesPath, "PUT", "/:id", handler.UpdateRule, RouteSpec{
Summary: "更新轮询告警规则",
Tags: []string{"轮询管理-告警"},
Input: new(dto.UpdatePollingAlertRuleParams),
Output: nil,
Auth: true,
})
Register(rules, doc, rulesPath, "DELETE", "/:id", handler.DeleteRule, RouteSpec{
Summary: "删除轮询告警规则",
Tags: []string{"轮询管理-告警"},
Input: new(dto.IDReq),
Output: nil,
Auth: true,
})
// 告警历史
historyPath := basePath + "/polling-alert-history"
Register(router, doc, historyPath, "GET", "/polling-alert-history", handler.ListHistory, RouteSpec{
Summary: "获取轮询告警历史",
Tags: []string{"轮询管理-告警"},
Input: new(dto.ListPollingAlertHistoryReq),
Output: new(dto.PollingAlertHistoryListResp),
Auth: true,
})
}