Skip to content

Commit d574654

Browse files
authoredJun 3, 2024
fix: missed renames from name to id in plugins (#1079)
Signed-off-by: Gabriele Baldoni <gabriele.baldoni@gmail.com>
1 parent 16f1c43 commit d574654

File tree

4 files changed

+24
-23
lines changed

4 files changed

+24
-23
lines changed
 

‎plugins/zenoh-plugin-trait/src/manager.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -322,21 +322,21 @@ impl<StartArgs: PluginStartArgs + 'static, Instance: PluginInstance + 'static> P
322322
);
323323
let mut plugins = Vec::new();
324324
for plugin in self.declared_plugins_iter() {
325-
let name = unsafe { keyexpr::from_str_unchecked(plugin.name()) };
326-
if names.includes(name) {
325+
let id = unsafe { keyexpr::from_str_unchecked(plugin.id()) };
326+
if names.includes(id) {
327327
let status = PluginStatusRec::new(plugin.as_status());
328328
plugins.push(status);
329329
}
330330
// for running plugins append their subplugins prepended with the running plugin name
331331
if let Some(plugin) = plugin.loaded() {
332332
if let Some(plugin) = plugin.started() {
333-
if let [names, ..] = names.strip_prefix(name)[..] {
333+
if let [names, ..] = names.strip_prefix(id)[..] {
334334
plugins.append(
335335
&mut plugin
336336
.instance()
337337
.plugins_status(names)
338338
.into_iter()
339-
.map(|s| s.prepend_name(name))
339+
.map(|s| s.prepend_name(id))
340340
.collect(),
341341
);
342342
}

‎plugins/zenoh-plugin-trait/src/manager/static_plugin.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,10 @@ where
106106
}
107107
fn start(&mut self, args: &StartArgs) -> ZResult<&mut dyn StartedPlugin<StartArgs, Instance>> {
108108
if self.instance.is_none() {
109-
tracing::debug!("Plugin `{}` started", self.name());
109+
tracing::debug!("Plugin `{}` started", self.id());
110110
self.instance = Some(P::start(self.id(), args)?);
111111
} else {
112-
tracing::warn!("Plugin `{}` already started", self.name());
112+
tracing::warn!("Plugin `{}` already started", self.id());
113113
}
114114
Ok(self)
115115
}

‎zenoh/src/net/runtime/adminspace.rs

+12-11
Original file line numberDiff line numberDiff line change
@@ -103,20 +103,21 @@ impl AdminSpace {
103103
start_args: &Runtime,
104104
required: bool,
105105
) -> ZResult<()> {
106+
let id = &config.id;
106107
let name = &config.name;
107-
let declared = if let Some(declared) = plugin_mgr.plugin_mut(name) {
108-
tracing::warn!("Plugin `{}` was already declared", declared.name());
108+
let declared = if let Some(declared) = plugin_mgr.plugin_mut(id) {
109+
tracing::warn!("Plugin `{}` was already declared", declared.id());
109110
declared
110111
} else if let Some(paths) = &config.paths {
111-
plugin_mgr.declare_dynamic_plugin_by_paths(name, name, paths, required)?
112+
plugin_mgr.declare_dynamic_plugin_by_paths(id, name, paths, required)?
112113
} else {
113-
plugin_mgr.declare_dynamic_plugin_by_name(name, name, required)?
114+
plugin_mgr.declare_dynamic_plugin_by_name(id, name, required)?
114115
};
115116

116117
let loaded = if let Some(loaded) = declared.loaded_mut() {
117118
tracing::warn!(
118119
"Plugin `{}` was already loaded from {}",
119-
loaded.name(),
120+
loaded.id(),
120121
loaded.path()
121122
);
122123
loaded
@@ -125,12 +126,12 @@ impl AdminSpace {
125126
};
126127

127128
if let Some(started) = loaded.started_mut() {
128-
tracing::warn!("Plugin `{}` was already started", started.name());
129+
tracing::warn!("Plugin `{}` was already started", started.id());
129130
} else {
130131
let started = loaded.start(start_args)?;
131132
tracing::info!(
132133
"Successfully started plugin `{}` from {}",
133-
started.name(),
134+
started.id(),
134135
started.path()
135136
);
136137
};
@@ -768,7 +769,7 @@ fn plugins_data(context: &AdminContext, query: Query) {
768769
let statuses = guard.plugins_status(names);
769770
for status in statuses {
770771
tracing::debug!("plugin status: {:?}", status);
771-
let key = root_key.join(status.name()).unwrap();
772+
let key = root_key.join(status.id()).unwrap();
772773
let status = serde_json::to_value(status).unwrap();
773774
if let Err(e) = query.reply(Ok(Sample::new(key, Value::from(status)))).res() {
774775
tracing::error!("Error sending AdminSpace reply: {:?}", e);
@@ -834,15 +835,15 @@ fn plugins_status(context: &AdminContext, query: Query) {
834835
}
835836
}
836837
Ok(Err(e)) => {
837-
tracing::error!("Plugin {} bailed from responding to {}: {}", plugin.name(), query.key_expr(), e)
838+
tracing::error!("Plugin {} bailed from responding to {}: {}", plugin.id(), query.key_expr(), e)
838839
}
839840
Err(e) => match e
840841
.downcast_ref::<String>()
841842
.map(|s| s.as_str())
842843
.or_else(|| e.downcast_ref::<&str>().copied())
843844
{
844-
Some(e) => tracing::error!("Plugin {} panicked while responding to {}: {}", plugin.name(), query.key_expr(), e),
845-
None => tracing::error!("Plugin {} panicked while responding to {}. The panic message couldn't be recovered.", plugin.name(), query.key_expr()),
845+
Some(e) => tracing::error!("Plugin {} panicked while responding to {}: {}", plugin.id(), query.key_expr(), e),
846+
None => tracing::error!("Plugin {} panicked while responding to {}. The panic message couldn't be recovered.", plugin.id(), query.key_expr()),
846847
},
847848
}
848849
});

‎zenoh/src/plugins/loader.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub(crate) fn load_plugin(
2424
required: bool,
2525
) -> ZResult<()> {
2626
let declared = if let Some(declared) = plugin_mgr.plugin_mut(name) {
27-
tracing::warn!("Plugin `{}` was already declared", declared.name());
27+
tracing::warn!("Plugin `{}` was already declared", declared.id());
2828
declared
2929
} else if let Some(paths) = paths {
3030
plugin_mgr.declare_dynamic_plugin_by_paths(name, id, paths, required)?
@@ -35,7 +35,7 @@ pub(crate) fn load_plugin(
3535
if let Some(loaded) = declared.loaded_mut() {
3636
tracing::warn!(
3737
"Plugin `{}` was already loaded from {}",
38-
loaded.name(),
38+
loaded.id(),
3939
loaded.path()
4040
);
4141
} else {
@@ -76,13 +76,13 @@ pub(crate) fn start_plugins(runtime: &Runtime) {
7676
tracing::info!(
7777
"Starting {req} plugin \"{name}\"",
7878
req = if required { "required" } else { "" },
79-
name = plugin.name()
79+
name = plugin.id()
8080
);
8181
match plugin.start(runtime) {
8282
Ok(_) => {
8383
tracing::info!(
8484
"Successfully started plugin {} from {:?}",
85-
plugin.name(),
85+
plugin.id(),
8686
plugin.path()
8787
);
8888
}
@@ -94,7 +94,7 @@ pub(crate) fn start_plugins(runtime: &Runtime) {
9494
if required {
9595
panic!(
9696
"Plugin \"{}\" failed to start: {}",
97-
plugin.name(),
97+
plugin.id(),
9898
if report.is_empty() {
9999
"no details provided"
100100
} else {
@@ -104,7 +104,7 @@ pub(crate) fn start_plugins(runtime: &Runtime) {
104104
} else {
105105
tracing::error!(
106106
"Required plugin \"{}\" failed to start: {}",
107-
plugin.name(),
107+
plugin.id(),
108108
if report.is_empty() {
109109
"no details provided"
110110
} else {

0 commit comments

Comments
 (0)