feat(plugin_loader): Phase 134 P0 - Best-effort plugin loading (continue on failures)
This commit is contained in:
@ -11,12 +11,50 @@ use std::sync::Arc;
|
||||
|
||||
pub(super) fn load_all_plugins(loader: &PluginLoaderV2) -> BidResult<()> {
|
||||
let config = loader.config.as_ref().ok_or(BidError::PluginError)?;
|
||||
for (lib_name, lib_def) in &config.libraries {
|
||||
load_plugin(loader, lib_name, lib_def)?;
|
||||
|
||||
// Phase 134 P0: Best-effort loading
|
||||
// Failures don't stop the entire load process
|
||||
let mut loaded_count = 0;
|
||||
let mut failed_count = 0;
|
||||
|
||||
// Load libraries in deterministic order (sorted by name)
|
||||
let mut lib_items: Vec<_> = config.libraries.iter().collect();
|
||||
lib_items.sort_by_key(|(name, _)| *name);
|
||||
|
||||
for (lib_name, lib_def) in lib_items {
|
||||
match load_plugin(loader, lib_name, lib_def) {
|
||||
Ok(()) => loaded_count += 1,
|
||||
Err(_) => {
|
||||
failed_count += 1;
|
||||
// Log already printed by load_plugin, continue
|
||||
}
|
||||
}
|
||||
}
|
||||
for (plugin_name, root) in &config.plugins {
|
||||
load_plugin_from_root(loader, plugin_name, root)?;
|
||||
|
||||
// Load plugins in deterministic order (sorted by name)
|
||||
let mut plugin_items: Vec<_> = config.plugins.iter().collect();
|
||||
plugin_items.sort_by_key(|(name, _)| *name);
|
||||
|
||||
for (plugin_name, root) in plugin_items {
|
||||
match load_plugin_from_root(loader, plugin_name, root) {
|
||||
Ok(()) => loaded_count += 1,
|
||||
Err(_) => {
|
||||
failed_count += 1;
|
||||
// Log already printed by load_plugin_from_root, continue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Phase 134 P0: Log summary
|
||||
if failed_count > 0 {
|
||||
get_global_ring0().log.warn(&format!(
|
||||
"[plugin/init] loaded {} plugins, {} failed",
|
||||
loaded_count, failed_count
|
||||
));
|
||||
}
|
||||
|
||||
// Continue with singleton prebirth even if some plugins failed
|
||||
// This follows "fail gracefully" principle: partially working state is better than complete failure
|
||||
super::singletons::prebirth_singletons(loader)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user