(config: &PluginConfig)
| 1268 | } |
| 1269 | |
| 1270 | async fn initialize_plugin_components(config: &PluginConfig) -> Result<Vec<PluginRegistration>> { |
| 1271 | ensure_builtin_plugins_registered()?; |
| 1272 | let totals = plugin_component_totals(config); |
| 1273 | let mut ordinals: HashMap<&str, usize> = HashMap::new(); |
| 1274 | let mut registrations = vec![]; |
| 1275 | |
| 1276 | for component in config |
| 1277 | .components |
| 1278 | .iter() |
| 1279 | .filter(|component| component.enabled) |
| 1280 | { |
| 1281 | let Some(plugin) = lookup_plugin(&component.kind) else { |
| 1282 | rollback_registrations(&mut registrations); |
| 1283 | return Err(PluginError::NotFound(format!( |
| 1284 | "plugin component '{}' is not registered", |
| 1285 | component.kind |
| 1286 | ))); |
| 1287 | }; |
| 1288 | |
| 1289 | let ordinal = ordinals |
| 1290 | .entry(component.kind.as_str()) |
| 1291 | .and_modify(|value| *value += 1) |
| 1292 | .or_insert(1); |
| 1293 | let namespace = component_namespace( |
| 1294 | &component.kind, |
| 1295 | *ordinal, |
| 1296 | totals.get(component.kind.as_str()).copied().unwrap_or(1), |
| 1297 | ); |
| 1298 | |
| 1299 | let mut ctx = PluginRegistrationContext::with_namespace(namespace); |
| 1300 | if let Err(err) = plugin.register(&component.config, &mut ctx).await { |
| 1301 | let mut just_registered = ctx.into_registrations(); |
| 1302 | rollback_registrations(&mut just_registered); |
| 1303 | rollback_registrations(&mut registrations); |
| 1304 | return Err(err); |
| 1305 | } |
| 1306 | registrations.extend(ctx.into_registrations()); |
| 1307 | } |
| 1308 | |
| 1309 | Ok(registrations) |
| 1310 | } |
| 1311 | |
| 1312 | fn store_active_plugin_configuration( |
| 1313 | config: PluginConfig, |
no test coverage detected