All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 9m46s
【核心变更】
1. 停复机逻辑统一(StopResumeService)
- 新增 EvaluateAndAct 统一入口,封装三条件停复机判断
- 停机条件:无套餐(no_package) / 流量耗尽(traffic_exhausted) / 未实名(not_realname)
- 复机条件:stop_reason 合规 + 有套餐且未耗尽 + 已实名或行业卡
- 修复设备套餐 Bug:hasValidPackage 按 device_id 查套餐,而非仅 iot_card_id
- 设备维度停复机加幂等锁(Redis SetNX,TTL 30s),防止多卡并发重复调 Gateway
2. Redis 分片队列(PollingQueueManager)
- 新建 queue_manager.go,封装所有轮询 Redis 操作
- 16 分片 Sorted Set,Key 格式:polling:shard:{shardID}:queue:{taskType}
- Lua 脚本原子出队(ZRANGEBYSCORE + 分批 ZREM),消除竞态窗口
- 新增背压检测:队列深度超 50 万时 Scheduler 跳过该分片
- RemoveFromAllQueues 覆盖 4 种任务类型(含 protect)
3. Handler 拆分(polling_handler.go 1360行 → 5个专注文件)
- polling_base.go:共享基类(并发控制/卡缓存/重入队)
- polling_realname_handler.go:实名采集,实名 0→1 时立即触发复机
- polling_carddata_handler.go:流量采集,保留跨月边界检测逻辑
- polling_package_handler.go:套餐采集,委托 EvaluateAndAct 决策
- polling_protect_handler.go:保护期一致性检查,保护期内强制修正
4. 配置管理(PollingConfigManager)
- 新建 config_manager.go,从 scheduler.go 提取配置职责
- 内存缓存 + 5 分钟定时刷新,刷新失败保留原缓存
- 修复 getCardCondition:停机卡返回 suspended,不再错配 activated 配置
5. 渐进式初始化(CardInitializer)
- 新建 initializer.go,分批加载(每批 10 万),批次间 sleep 500ms
- 过滤 enable_polling=false 的卡,初始化完成前 Scheduler 不出队
6. 卡生命周期服务(PollingLifecycleService)
- 新建 lifecycle_service.go,替代已删除的 callbacks.go 和 api_callback.go
- OnCardCreated/OnCardEnabled/OnCardStatusChanged 入队前检查 enable_polling
7. Scheduler 精简(1000+行 → 227行)
- 保留纯调度循环:scheduleLoop + processShardSchedule + enqueueBatch
- 保留每 10 秒触发套餐过期检测和流量重置
- 移除所有 DB 操作、配置加载、卡初始化逻辑
8. 轮询管控 API(enable_polling)
- 新增 PUT /api/admin/assets/:id/polling-status 接口
- 支持对设备/卡维度开关轮询,关闭后从所有分片队列移除
9. 数据库迁移
- 000103:tb_device 新增 enable_polling 字段(boolean, NOT NULL, DEFAULT true)
- 000104:新增 suspended 轮询配置,为 activated 配置补全 protect_check_interval
【文件统计】
- 新增:19 个文件(handler × 5、polling 组件 × 4、迁移 × 3 等)
- 修改:20 个文件(bootstrap 注入、store 接口、monitoring 适配分片等)
- 删除:3 个文件(polling_handler.go、callbacks.go、api_callback.go)
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)
Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
116 lines
3.6 KiB
JSON
116 lines
3.6 KiB
JSON
{
|
|
"name": ".opencode",
|
|
"lockfileVersion": 3,
|
|
"requires": true,
|
|
"packages": {
|
|
"": {
|
|
"dependencies": {
|
|
"@opencode-ai/plugin": "1.3.17"
|
|
}
|
|
},
|
|
"node_modules/@opencode-ai/plugin": {
|
|
"version": "1.3.17",
|
|
"resolved": "https://registry.npmjs.org/@opencode-ai/plugin/-/plugin-1.3.17.tgz",
|
|
"integrity": "sha512-N5lckFtYvEu2R8K1um//MIOTHsJHniF2kHoPIWPCrxKG5Jpismt1ISGzIiU3aKI2ht/9VgcqKPC5oZFLdmpxPw==",
|
|
"license": "MIT",
|
|
"dependencies": {
|
|
"@opencode-ai/sdk": "1.3.17",
|
|
"zod": "4.1.8"
|
|
},
|
|
"peerDependencies": {
|
|
"@opentui/core": ">=0.1.96",
|
|
"@opentui/solid": ">=0.1.96"
|
|
},
|
|
"peerDependenciesMeta": {
|
|
"@opentui/core": {
|
|
"optional": true
|
|
},
|
|
"@opentui/solid": {
|
|
"optional": true
|
|
}
|
|
}
|
|
},
|
|
"node_modules/@opencode-ai/sdk": {
|
|
"version": "1.3.17",
|
|
"resolved": "https://registry.npmjs.org/@opencode-ai/sdk/-/sdk-1.3.17.tgz",
|
|
"integrity": "sha512-2+MGgu7wynqTBwxezR01VAGhILXlpcHDY/pF7SWB87WOgLt3kD55HjKHNj6PWxyY8n575AZolR95VUC3gtwfmA==",
|
|
"license": "MIT",
|
|
"dependencies": {
|
|
"cross-spawn": "7.0.6"
|
|
}
|
|
},
|
|
"node_modules/cross-spawn": {
|
|
"version": "7.0.6",
|
|
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",
|
|
"integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==",
|
|
"license": "MIT",
|
|
"dependencies": {
|
|
"path-key": "^3.1.0",
|
|
"shebang-command": "^2.0.0",
|
|
"which": "^2.0.1"
|
|
},
|
|
"engines": {
|
|
"node": ">= 8"
|
|
}
|
|
},
|
|
"node_modules/isexe": {
|
|
"version": "2.0.0",
|
|
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
|
|
"integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==",
|
|
"license": "ISC"
|
|
},
|
|
"node_modules/path-key": {
|
|
"version": "3.1.1",
|
|
"resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz",
|
|
"integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==",
|
|
"license": "MIT",
|
|
"engines": {
|
|
"node": ">=8"
|
|
}
|
|
},
|
|
"node_modules/shebang-command": {
|
|
"version": "2.0.0",
|
|
"resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz",
|
|
"integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==",
|
|
"license": "MIT",
|
|
"dependencies": {
|
|
"shebang-regex": "^3.0.0"
|
|
},
|
|
"engines": {
|
|
"node": ">=8"
|
|
}
|
|
},
|
|
"node_modules/shebang-regex": {
|
|
"version": "3.0.0",
|
|
"resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz",
|
|
"integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==",
|
|
"license": "MIT",
|
|
"engines": {
|
|
"node": ">=8"
|
|
}
|
|
},
|
|
"node_modules/which": {
|
|
"version": "2.0.2",
|
|
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
|
|
"integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
|
|
"license": "ISC",
|
|
"dependencies": {
|
|
"isexe": "^2.0.0"
|
|
},
|
|
"bin": {
|
|
"node-which": "bin/node-which"
|
|
},
|
|
"engines": {
|
|
"node": ">= 8"
|
|
}
|
|
},
|
|
"node_modules/zod": {
|
|
"version": "4.1.8",
|
|
"license": "MIT",
|
|
"funding": {
|
|
"url": "https://github.com/sponsors/colinhacks"
|
|
}
|
|
}
|
|
}
|
|
}
|