MCPcopy Create free account
hub / github.com/NVIDIA/NeMo-Relay / initialize_plugin_components

Function initialize_plugin_components

crates/core/src/plugin.rs:1270–1310  ·  view source on GitHub ↗
(config: &PluginConfig)

Source from the content-addressed store, hash-verified

1268}
1269
1270async 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
1312fn store_active_plugin_configuration(
1313 config: PluginConfig,

Callers 1

initialize_plugins_exactFunction · 0.85

Calls 9

plugin_component_totalsFunction · 0.85
lookup_pluginFunction · 0.85
rollback_registrationsFunction · 0.85
component_namespaceFunction · 0.85
getMethod · 0.80
into_registrationsMethod · 0.80
registerMethod · 0.65
as_strMethod · 0.45

Tested by

no test coverage detected