feat: implement ConfigReloadRequest handler in ServiceManager
Complete the config hot-reload flow: - ServiceManager receives ConfigReloadRequest from HTTP plugin - Reloads config from source_path using AppConfig::from_file - Updates internal config Arc - Broadcasts ConfigReloaded(new_config) to all plugins - Logs error on reload failure without crashing This closes the P0 gap identified by architect Wang Siyuan: the HTTP /api/config save endpoint promised hot-reload but ServiceManager only had a TODO placeholder. cargo check: 0 warnings, cargo test: 22/22 passed Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -128,7 +128,17 @@ impl ServiceManager {
|
|||||||
}
|
}
|
||||||
Message::ConfigReloadRequest => {
|
Message::ConfigReloadRequest => {
|
||||||
println!("[ServiceManager] 收到配置重载请求");
|
println!("[ServiceManager] 收到配置重载请求");
|
||||||
// TODO: 重载配置并广播 ConfigReloaded
|
match AppConfig::from_file(&self.config.source_path) {
|
||||||
|
Ok(new_config) => {
|
||||||
|
let new_config = Arc::new(new_config);
|
||||||
|
self.config = Arc::clone(&new_config);
|
||||||
|
println!("[ServiceManager] 配置重载成功,广播 ConfigReloaded");
|
||||||
|
self.broadcast_message(Message::ConfigReloaded(new_config));
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
eprintln!("[ServiceManager] 配置重载失败: {}", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Message::PluginReady(id) => {
|
Message::PluginReady(id) => {
|
||||||
println!("[ServiceManager] 插件 '{}' 就绪", id);
|
println!("[ServiceManager] 插件 '{}' 就绪", id);
|
||||||
|
|||||||
Reference in New Issue
Block a user