refactor: inject Rust acceleration settings

This commit is contained in:
jxxghp
2026-08-23 01:37:08 +08:00
parent e63745f40b
commit d15c65b108
4 changed files with 19 additions and 8 deletions
+12 -2
View File
@@ -1,8 +1,9 @@
import importlib
import logging
from functools import lru_cache
from typing import List, Optional, Tuple
from app.runtime.config import settings
from app.application.configuration import get_runtime_settings
from app.runtime.log import logger, log_settings
try:
@@ -14,6 +15,15 @@ else:
_import_error = None
def _rust_accel_enabled() -> bool:
"""读取 Rust 开关快照,组合根未装配时回退旧 Settings。"""
try:
return bool(get_runtime_settings().get("RUST_ACCEL"))
except RuntimeError:
legacy_settings = importlib.import_module("app.runtime.config").settings
return bool(legacy_settings.RUST_ACCEL)
def is_available() -> bool:
"""
判断 Rust 扩展是否可用。
@@ -25,7 +35,7 @@ def is_config_enabled() -> bool:
"""
判断系统配置是否允许使用 Rust 加速。
"""
return bool(settings.RUST_ACCEL)
return _rust_accel_enabled()
def is_enabled() -> bool:
@@ -70,7 +70,7 @@ MoviePilot V3 当前不是“目录混乱、必须推倒重来”的状态。第
| legacy 默认模块契约 | 0 个宿主观察方法;未知动态方法保留 fallback | 所有静态宿主方法已有显式 V2 spec;真实 fallback 命中由 `module.contract.legacy_hit` 观测 |
| 事件枚举 | 53 | 66 个静态 producer、15 个静态 consumer |
| 专用 EventData model | 53 | Event Contract Registry 已为全部事件登记 typed payload/fallback 原因 |
| 直接读取 `settings` 的文件 | 118 | 仍按模块族迁移,动态协议和安全端口暂保留 |
| 直接读取 `settings` 的文件 | 117 | 仍按模块族迁移,动态协议和安全端口暂保留 |
| `SystemConfigOper()` | 1 个 | 仅组合根创建 `SystemConfigService` 时保留 |
| Model 上的 DB 查询装饰器 | 119 | `db_update`/`async_db_update` 为 0;查询 ABI 继续按 canonical 用例迁移 |
| 路由端点 | 335 | 11 个已装饰端点超过 80 行,最大 400 行 |
@@ -1022,6 +1022,7 @@ MFA/Passkey 专项测试与架构门禁通过,密钥类配置仍保留在安
2026-08-23 将 `OcrHelper` 的服务地址改为通过 `RuntimeSettingsService` 或显式构造参数取得;导入早期保留旧模块回退,自动补齐 `/captcha/base64` 路径。配置债务由 121 个文件降至 120 个文件,并补充 OCR 地址注入回归测试。
2026-08-23 将 `CookieCloudHelper` 的五项运行配置改为通过 `RuntimeSettingsService` 读取;同步期间仍获取最新值,未装配时保留旧 Settings ABI。配置债务由 120 个文件降至 119 个文件,并通过 CookieCloud 路由与站点回归测试。
2026-08-23 将 DoH 开关、域名和解析器配置改为通过 `RuntimeSettingsService` 动态读取;socket 补丁、热更新、缓存和线程池关闭语义保持不变,未装配时保留旧 Settings ABI。配置债务由 119 个文件降至 118 个文件,并通过 DoH 与生命周期回归测试。
2026-08-23 将 Rust 加速开关改为通过 `RuntimeSettingsService` 动态读取;扩展可用性、异常回退和公开适配器 API 保持不变,未装配时保留旧 Settings ABI。配置债务由 118 个文件降至 117 个文件,并通过 Rust 解析与开关回归测试。
**收口记录(2026-08-22**`reidentify_cache``nettest``scrape`、OpenAI `chat_completions/responses``get_logging` 和 Web Agent SSE 均改为稳定公开入口委托私有编排实现;四个消息交互 Handler 的公开方法也保留 ABI 并委托私有状态机。复杂度基线已清零,API/Application/Chain 入口预算、异步阻塞 ratchet 均通过;复杂度及兼容专项合计 252 项测试通过。
随后将 `TransferChain.do_transfer` 的公开入口收口为稳定兼容 Facade,先提取媒体身份规范化阶段,保留显式
@@ -9,7 +9,7 @@
"root": "app"
},
"settings_imports": {
"count": 118,
"count": 117,
"files": [
"app/adapters/cache/backends.py",
"app/adapters/cache/redis.py",
@@ -20,7 +20,6 @@
"app/adapters/system/plugin/dependency.py",
"app/adapters/system/plugin/package.py",
"app/adapters/system/resource.py",
"app/adapters/system/rust.py",
"app/adapters/web/security/access.py",
"app/agent/capabilities/adapter.py",
"app/agent/llm/capability.py",
+4 -3
View File
@@ -13,8 +13,8 @@
"runtime_to_db": [],
"workflow_to_db": []
},
"edge_count": 6419,
"edge_sha256": "7e3db5ef8bc9be8d21706ad7a5f4b256430ea876afef66ca9ecf33ea2ff3c64e",
"edge_count": 6420,
"edge_sha256": "c1d92730a7755f0b5da8d8f9b8ecc4b828f76b8eb90b6967d8f5a8bc600b0727",
"edges": [
"app -> app.runtime",
"app -> app.runtime.compat",
@@ -156,8 +156,9 @@
"app.adapters.system.resource -> app.runtime",
"app.adapters.system.resource -> app.runtime.config",
"app.adapters.system.resource -> app.runtime.log",
"app.adapters.system.rust -> app.application",
"app.adapters.system.rust -> app.application.configuration",
"app.adapters.system.rust -> app.runtime",
"app.adapters.system.rust -> app.runtime.config",
"app.adapters.system.rust -> app.runtime.log",
"app.adapters.web.correlation -> app.runtime",
"app.adapters.web.correlation -> app.runtime.correlation",