Files
junhong_cmp_fiber/internal/model/dto/polling_cleanup_dto.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

104 lines
5.4 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package dto
import "time"
// CreateDataCleanupConfigReq 创建数据清理配置请求
type CreateDataCleanupConfigReq struct {
TargetTable string `json:"table_name" validate:"required,max=100" description:"表名"`
RetentionDays int `json:"retention_days" validate:"required,min=7" description:"保留天数最少7天"`
BatchSize int `json:"batch_size" validate:"omitempty,min=1000,max=100000" description:"每批删除条数默认10000"`
Description string `json:"description" validate:"omitempty,max=500" description:"配置说明"`
}
// UpdateDataCleanupConfigReq 更新数据清理配置请求Body 部分)
type UpdateDataCleanupConfigReq struct {
RetentionDays *int `json:"retention_days" validate:"omitempty,min=7" description:"保留天数"`
BatchSize *int `json:"batch_size" validate:"omitempty,min=1000,max=100000" description:"每批删除条数"`
Enabled *int `json:"enabled" validate:"omitempty,oneof=0 1" description:"是否启用0-禁用1-启用"`
Description *string `json:"description" validate:"omitempty,max=500" description:"配置说明"`
}
// UpdateDataCleanupConfigParams 更新数据清理配置参数(包含路径参数和 Body
type UpdateDataCleanupConfigParams struct {
IDReq
UpdateDataCleanupConfigReq
}
// DataCleanupConfigResp 数据清理配置响应
type DataCleanupConfigResp struct {
ID uint `json:"id" description:"配置ID"`
TargetTable string `json:"table_name" description:"表名"`
RetentionDays int `json:"retention_days" description:"保留天数"`
BatchSize int `json:"batch_size" description:"每批删除条数"`
Enabled int `json:"enabled" description:"是否启用0-禁用1-启用"`
Description string `json:"description" description:"配置说明"`
CreatedAt time.Time `json:"created_at" description:"创建时间"`
UpdatedAt time.Time `json:"updated_at" description:"更新时间"`
UpdatedBy *uint `json:"updated_by,omitempty" description:"更新人ID"`
}
// DataCleanupConfigListResp 数据清理配置列表响应
type DataCleanupConfigListResp struct {
Items []*DataCleanupConfigResp `json:"items" description:"配置列表"`
}
// DataCleanupLogResp 数据清理日志响应
type DataCleanupLogResp struct {
ID uint `json:"id" description:"日志ID"`
TargetTable string `json:"table_name" description:"表名"`
CleanupType string `json:"cleanup_type" description:"清理类型scheduled/manual"`
RetentionDays int `json:"retention_days" description:"保留天数"`
DeletedCount int64 `json:"deleted_count" description:"删除记录数"`
DurationMs int64 `json:"duration_ms" description:"执行耗时(毫秒)"`
Status string `json:"status" description:"状态success/failed/running"`
ErrorMessage string `json:"error_message,omitempty" description:"错误信息"`
StartedAt time.Time `json:"started_at" description:"开始时间"`
CompletedAt *time.Time `json:"completed_at,omitempty" description:"完成时间"`
TriggeredBy *uint `json:"triggered_by,omitempty" description:"触发人ID"`
}
// DataCleanupLogListResp 数据清理日志列表响应
type DataCleanupLogListResp struct {
Items []*DataCleanupLogResp `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:"总页数"`
}
// ListDataCleanupLogReq 查询数据清理日志请求
type ListDataCleanupLogReq struct {
TableName string `json:"table_name" query:"table_name" description:"表名筛选"`
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:"每页数量"`
}
// DataCleanupPreviewResp 数据清理预览响应
type DataCleanupPreviewResp struct {
Items []*DataCleanupPreviewItem `json:"items" description:"预览列表"`
}
// DataCleanupPreviewItem 数据清理预览项
type DataCleanupPreviewItem struct {
TableName string `json:"table_name" description:"表名"`
RetentionDays int `json:"retention_days" description:"保留天数"`
RecordCount int64 `json:"record_count" description:"待清理记录数"`
Description string `json:"description" description:"配置说明"`
}
// DataCleanupProgressResp 数据清理进度响应
type DataCleanupProgressResp struct {
IsRunning bool `json:"is_running" description:"是否正在运行"`
CurrentTable string `json:"current_table,omitempty" description:"当前清理的表"`
TotalTables int `json:"total_tables" description:"总表数"`
ProcessedTables int `json:"processed_tables" description:"已处理表数"`
TotalDeleted int64 `json:"total_deleted" description:"已删除记录数"`
StartedAt *time.Time `json:"started_at,omitempty" description:"开始时间"`
LastLog *DataCleanupLogResp `json:"last_log,omitempty" description:"最近一条清理日志"`
}
// TriggerDataCleanupReq 手动触发数据清理请求
type TriggerDataCleanupReq struct {
TableName string `json:"table_name" validate:"omitempty,max=100" description:"表名,为空则清理所有"`
}