Issue#6·P2: Dashboard 后端 3 端点——①/ops/system/overview(五子系统 gateway/consumer/mysql/redis/kafka;up|degraded|down|unknown 四态诚实:lag≥10k=degraded、Redis 降级=down 不假绿;admin|ops 角色门,LagReader 闭包注入复用 Day55 只读实例);②/stats/biz(两维分布 by_business=sms|video 空值归一 + by_send_type=batch|personal|timer|file;口径修正留痕:原契约 biz_type 属审核域 audit_record 非 task 维度,以 send_type 呈现更贴运营语义;days 1~30 缺省 7);③/stats/realtime(60s 窗 idx_detail_created 覆盖索引 COUNT 零回表;平台=全局+Top5 账号+username 补齐,客户=仅自己);④openapi 1.4.0→1.5.0(+3 端点);⑤测试=ops_handler_test.go 3 组(平台/客户双口径、四态+lag 千分位、customer 403 门);门禁=vet✓/lint api 域 0/全量 -race 除 channel 存量 flaky(单跑×2 绿,挂账);人工验收挂起与 P3/P4 统一走;工作区遗留 8 文件(先前会话半成品)不纳入本提交边界
This commit is contained in:
+17
-4
@@ -18,9 +18,9 @@ import (
|
||||
"go-sms/internal/pkg/metrics"
|
||||
"go-sms/internal/pkg/queue"
|
||||
"go-sms/internal/pkg/storage"
|
||||
chrepo "go-sms/internal/repository/clickhouse"
|
||||
cmppproto "go-sms/internal/protocol/cmpp"
|
||||
smppproto "go-sms/internal/protocol/smpp"
|
||||
chrepo "go-sms/internal/repository/clickhouse"
|
||||
"go-sms/internal/service/access"
|
||||
"go-sms/internal/service/account"
|
||||
"go-sms/internal/service/archive"
|
||||
@@ -102,6 +102,8 @@ func main() {
|
||||
// Day 48:全流程状态机——拦截链(Day42)+sms-submit 统一出口(ProducerSink,
|
||||
// 替代 openapi 自投,预扣/拦截退费/审核拒绝退费在 SubmitService 内闭环)。
|
||||
// Kafka 降级(producer=nil)不注入 sink:发送由 ReclaimScanner DB 认领兜底。
|
||||
// Issue#6·P2:系统健康探针(lagR 未就绪时为 nil=unknown)。
|
||||
var healthLag func(ctx context.Context) (int64, error)
|
||||
pipelineOpts := []send.SubmitOption{send.WithInterceptorChain(ichain)}
|
||||
if p := a.Producer(); p != nil {
|
||||
pipelineOpts = append(pipelineOpts,
|
||||
@@ -146,6 +148,10 @@ func main() {
|
||||
}
|
||||
}()
|
||||
a.OnShutdown(func() { stopLag(); _ = lagR.Close() })
|
||||
// Issue#6·P2:健康探针复用同一 LagReader(只读)。
|
||||
healthLag = func(ctx context.Context) (int64, error) {
|
||||
return lagR.Total(ctx, []string{lagTopic})
|
||||
}
|
||||
}
|
||||
} else {
|
||||
a.Lg().Warn("submit_pipeline_kafka_disabled",
|
||||
@@ -234,6 +240,10 @@ func main() {
|
||||
// Issue#3 方案B:系统参数配置服务(system_config KV;/system/config
|
||||
// 管理端点 + access 系统默认接入码回退源;30s 读缓存+写即刻失效)。
|
||||
sysCfgSvc := sysconfig.New(db, 30*time.Second)
|
||||
healthDeps := &v1.HealthDeps{
|
||||
DB: db, Redis: a.Redis(), Lag: healthLag,
|
||||
StartTime: time.Now(), HTTPAddr: cfg.Server.HTTP.Addr, RedisMode: cfg.Redis.Mode,
|
||||
}
|
||||
v1.Register(rg, v1.Deps{
|
||||
Account: svc,
|
||||
Warning: warnSvc,
|
||||
@@ -268,6 +278,8 @@ func main() {
|
||||
// Issue#3 方案B:系统参数配置(/system/config;access 系统默认
|
||||
// 接入码回退数据源)。30s 读缓存+写即刻失效。
|
||||
SysConfig: sysCfgSvc,
|
||||
// Issue#6·P2:系统健康总览
|
||||
Health: healthDeps,
|
||||
})
|
||||
// Day68:运营总览汇总刷新(回补 30 天+60s ticker 增量 UPSERT stats_daily;
|
||||
// 幂等多实例无害,详见 stats_handler.go StartStatsRefresher)。
|
||||
@@ -323,9 +335,10 @@ func main() {
|
||||
// 提交复用 openapi 受理链;addr 空=不启用)。
|
||||
// Day 62:注入 CMPP 系统默认配额(账号级 0 回退;连接数/单链速度强制)。
|
||||
accSvc := access.New(db, openapiSvc, access.SystemLimits{
|
||||
MaxConns: cfg.Server.CMPP.MaxConnsPerAccount,
|
||||
SubmitRate: cfg.Server.CMPP.SubmitRatePerConn,
|
||||
LongSmsWindow: cfg.Server.CMPP.LongSmsWindow, // Day 71:≤0 默认 72h
|
||||
MaxConns: cfg.Server.CMPP.MaxConnsPerAccount,
|
||||
SubmitRate: cfg.Server.CMPP.SubmitRatePerConn,
|
||||
LongSmsWindow: cfg.Server.CMPP.LongSmsWindow, // Day 71:≤0 默认 72h
|
||||
LongSmsMaxGroup: cfg.Server.CMPP.LongSmsMaxGroup, // ≤0 默认 20 万(乱序容忍窗)
|
||||
})
|
||||
// Issue#3 方案B:系统配置源注入——账号 ext_code 为空时回退系统默认
|
||||
// 接入码 cmpp.default_ext_code(/system/config 可配)。
|
||||
|
||||
Reference in New Issue
Block a user