fix: 应用 xhigh 代码评审的跨端修复
ci / server (push) Failing after 13s
ci / design-tokens (push) Failing after 11s

来自 xhigh code review 的正确性/健壮性修复,覆盖全部五端:
- server:鉴权 fail-closed、计量交叉校验与配额扣穿处理、WS 网关并发与关闭顺序、
  billing 行锁、redis Lua 过期与设备槽刷新、config 解析
- desktop:会话 epoch 防串话、WS 重连与 401 处理、api 客户端复用、统一 usePoll 轮询
- android:握手时序、请求头封装、账户状态派生、按需重组
- ios:finalize 宽限、串行采集、错误文案服务端优先、删除死代码 CommitController

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
wangjia
2026-06-13 11:50:08 +08:00
parent 50b49f3cbe
commit b5ab92a57e
42 changed files with 2125 additions and 469 deletions
+25
View File
@@ -2,8 +2,12 @@
package config
import (
"encoding/json"
"log/slog"
"os"
"strconv"
"dudu/server/pkg/protocol"
)
type Config struct {
@@ -35,6 +39,10 @@ type Config struct {
OSSBucket string
OSSKeyID string
OSSKeySecret string
// AppLatest 启动时解析 APP_LATEST_JSON 一次(17G):平台→版本信息。
// 解析失败或未配置则为 nil/空,handler 据此返回 204,不 fail-fast。
AppLatest map[string]protocol.AppLatestResponse
}
func Load() Config {
@@ -64,9 +72,26 @@ func Load() Config {
OSSBucket: os.Getenv("OSS_BUCKET"),
OSSKeyID: os.Getenv("OSS_KEY_ID"),
OSSKeySecret: os.Getenv("OSS_KEY_SECRET"),
AppLatest: loadAppLatest(),
}
}
// loadAppLatest 启动时解析一次 APP_LATEST_JSON17G)。失败仅告警并返回 nil,
// 不 fail-fast——未配置此项时服务仍需正常启动。
func loadAppLatest() map[string]protocol.AppLatestResponse {
raw := os.Getenv("APP_LATEST_JSON")
if raw == "" {
return nil
}
var all map[string]protocol.AppLatestResponse
if err := json.Unmarshal([]byte(raw), &all); err != nil {
slog.Warn("invalid APP_LATEST_JSON, app update disabled", "err", err)
return nil
}
return all
}
func getenv(k, def string) string {
if v := os.Getenv(k); v != "" {
return v