modify 修复前端展示配置与实际插件配置不一致的bug
This commit is contained in:
@@ -195,6 +195,13 @@ tags = ["demo", "process-plugin"]
|
||||
greeting_prefix = "Hello"
|
||||
```
|
||||
|
||||
> **运行时配置的来源(两种模式)**:`[workers.config]` 与 `count` 在启动时按
|
||||
> `[workers.cache].launch_worker_count` 取值——`"toml"`(默认)以本文件为准,并把该段覆盖
|
||||
> 写入共享缓存(网关 `GET /admin/workers/<type>/config` 读缓存,因此前端显示文件值);
|
||||
> `"cache"` 以缓存为准(插件初始化即读缓存值,管理接口改动跨重启保持,本文件仅在缓存缺失时
|
||||
> 引导)。进程插件未配置 `[workers.cache]` 时无缓存句柄,恒为 toml 语义,且与网关内同名
|
||||
> 副本可能读到不同来源——需要与网关共享"改完即持久"的语义时请补上与网关一致的 `[workers.cache]`。
|
||||
|
||||
### 第 3 步:端点 TOML 定义
|
||||
|
||||
每个端点一个文件,如 `workers/<name>/config/workers/<name>/hello.toml`:
|
||||
|
||||
@@ -178,6 +178,23 @@ Rust 进程插件支持两种共享缓存后端(schema 与 Python `chongming-c
|
||||
编译启用:`bash build.sh dist "redis-cache"`(或 Cargo 依赖加 `chongming-worker-rs/redis-cache`)。
|
||||
未配置时单实例直接读写本地 `config.toml`(默认无缓存),行为一致。
|
||||
|
||||
#### 5.2.1 配置优先来源模式(`launch_worker_count`)
|
||||
|
||||
`[workers.cache].launch_worker_count` 与网关根 `config.toml` 的同名键语义一致,决定启动时
|
||||
`[workers.config]` 与 count 从哪一侧取值(SDK 的 `config::resolve_runtime_config` /
|
||||
`cache::resolve_worker_count` 按同一规则实现,与 Python SDK 对位):
|
||||
|
||||
| 环节 | `"toml"`(默认) | `"cache"` |
|
||||
| ---- | ---------------- | --------- |
|
||||
| 启动时 | 以 `config/workers/<type>/config.toml` 为准,并把该段**覆盖写入缓存**(网关读缓存 → 显示 toml 值) | 以缓存为准,插件初始化即读缓存值;缓存缺失才用 toml 引导并写回 |
|
||||
| 插件实际使用 | toml 值 | 缓存值(跨重启保持) |
|
||||
| `config_set` 改动的持久性 | 仅本次运行有效,下次启动被文件覆盖 | 跨重启保持(写入缓存) |
|
||||
|
||||
> 插件初始化读配置(如 `[workers.config].database`)请用 `config::effective_config_section`
|
||||
> 或 `database::init_database`(内部已按模式解析),**不要**直接读
|
||||
> `load_plugin_config(...).runtime["config"]`——后者恒为 toml 种子,cache 模式下会与网关
|
||||
> `get_config` 显示的缓存值不一致(表现为"前端显示缓存值、实际跑 toml")。
|
||||
|
||||
### 5.3 数据库 `[workers.config.database]`(可选)
|
||||
|
||||
见 §7。
|
||||
|
||||
Reference in New Issue
Block a user