Skip to content

Commit

Permalink
renamings, removed unnecessary sample configs
Browse files Browse the repository at this point in the history
  • Loading branch information
milyin committed Jan 23, 2024
1 parent 0b72c53 commit ff0ab93
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 168 deletions.
130 changes: 0 additions & 130 deletions plugin_test_config.json5

This file was deleted.

1 change: 0 additions & 1 deletion plugins/zenoh-backend-example/config.json5

This file was deleted.

11 changes: 5 additions & 6 deletions plugins/zenoh-backend-example/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
use std::{
collections::{hash_map::Entry, HashMap},
sync::Arc,
};

use async_std::sync::RwLock;
//
// Copyright (c) 2023 ZettaScale Technology
//
Expand All @@ -17,7 +11,12 @@ use async_std::sync::RwLock;
// Contributors:
// ZettaScale Zenoh Team, <[email protected]>
//
use async_std::sync::RwLock;
use async_trait::async_trait;
use std::{
collections::{hash_map::Entry, HashMap},
sync::Arc,
};
use zenoh::{prelude::OwnedKeyExpr, sample::Sample, time::Timestamp, value::Value};
use zenoh_backend_traits::{
config::{StorageConfig, VolumeConfig},
Expand Down
2 changes: 1 addition & 1 deletion plugins/zenoh-plugin-storage-manager/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ impl RunningPluginTrait for StorageRuntime {
});
let guard = self.0.lock().unwrap();
with_extended_string(&mut key, &["/volumes/"], |key| {
for plugin in guard.plugins_manager.started_plugins() {
for plugin in guard.plugins_manager.started_plugins_iter() {
with_extended_string(key, &[plugin.name()], |key| {
with_extended_string(key, &["/__path__"], |key| {
if keyexpr::new(key.as_str())
Expand Down
6 changes: 3 additions & 3 deletions plugins/zenoh-plugin-trait/src/compatibility.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,9 @@ impl Display for Compatibility {
#[repr(C)]
#[derive(Debug, PartialEq, Eq, Clone)]
pub struct RustVersion {
major: u64,
minor: u64,
patch: u64,
major: u32,
minor: u32,
patch: u32,
stable: bool,
commit: &'static str,
}
Expand Down
34 changes: 17 additions & 17 deletions plugins/zenoh-plugin-trait/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ impl<StartArgs: PluginStartArgs + 'static, Instance: PluginInstance + 'static>
}

/// Lists all plugins
pub fn declared_plugins(
pub fn declared_plugins_iter(
&self,
) -> impl Iterator<Item = &dyn DeclaredPlugin<StartArgs, Instance>> + '_ {
self.plugins
Expand All @@ -184,7 +184,7 @@ impl<StartArgs: PluginStartArgs + 'static, Instance: PluginInstance + 'static>
}

/// Lists all plugins mutable
pub fn declared_plugins_mut(
pub fn declared_plugins_iter_mut(
&mut self,
) -> impl Iterator<Item = &mut dyn DeclaredPlugin<StartArgs, Instance>> + '_ {
self.plugins
Expand All @@ -193,41 +193,41 @@ impl<StartArgs: PluginStartArgs + 'static, Instance: PluginInstance + 'static>
}

/// Lists the loaded plugins
pub fn loaded_plugins(
pub fn loaded_plugins_iter(
&self,
) -> impl Iterator<Item = &dyn LoadedPlugin<StartArgs, Instance>> + '_ {
self.declared_plugins().filter_map(|p| p.loaded())
self.declared_plugins_iter().filter_map(|p| p.loaded())
}

/// Lists the loaded plugins mutable
pub fn loaded_plugins_mut(
pub fn loaded_plugins_iter_mut(
&mut self,
) -> impl Iterator<Item = &mut dyn LoadedPlugin<StartArgs, Instance>> + '_ {
// self.plugins_mut().filter_map(|p| p.loaded_mut())
self.declared_plugins_mut().filter_map(|p| p.loaded_mut())
self.declared_plugins_iter_mut().filter_map(|p| p.loaded_mut())
}

/// Lists the started plugins
pub fn started_plugins(
pub fn started_plugins_iter(
&self,
) -> impl Iterator<Item = &dyn StartedPlugin<StartArgs, Instance>> + '_ {
self.loaded_plugins().filter_map(|p| p.started())
self.loaded_plugins_iter().filter_map(|p| p.started())
}

/// Lists the started plugins mutable
pub fn started_plugins_mut(
pub fn started_plugins_iter_mut(
&mut self,
) -> impl Iterator<Item = &mut dyn StartedPlugin<StartArgs, Instance>> + '_ {
self.loaded_plugins_mut().filter_map(|p| p.started_mut())
self.loaded_plugins_iter_mut().filter_map(|p| p.started_mut())
}

/// Returns single plugin record
/// Returns single plugin record by name
pub fn plugin(&self, name: &str) -> Option<&dyn DeclaredPlugin<StartArgs, Instance>> {
let index = self.get_plugin_index(name)?;
Some(&self.plugins[index])
}

/// Returns mutable plugin record
/// Returns mutable plugin record by name
pub fn plugin_mut(
&mut self,
name: &str,
Expand All @@ -236,25 +236,25 @@ impl<StartArgs: PluginStartArgs + 'static, Instance: PluginInstance + 'static>
Some(&mut self.plugins[index])
}

/// Returns loaded plugin record
/// Returns loaded plugin record by name
pub fn loaded_plugin(&self, name: &str) -> Option<&dyn LoadedPlugin<StartArgs, Instance>> {
self.plugin(name)?.loaded()
}

/// Returns mutable loaded plugin record
/// Returns mutable loaded plugin record by name
pub fn loaded_plugin_mut(
&mut self,
name: &str,
) -> Option<&mut dyn LoadedPlugin<StartArgs, Instance>> {
self.plugin_mut(name)?.loaded_mut()
}

/// Returns started plugin record
/// Returns started plugin record by name
pub fn started_plugin(&self, name: &str) -> Option<&dyn StartedPlugin<StartArgs, Instance>> {
self.loaded_plugin(name)?.started()
}

/// Returns mutable started plugin record
/// Returns mutable started plugin record by name
pub fn started_plugin_mut(
&mut self,
name: &str,
Expand All @@ -273,7 +273,7 @@ impl<StartArgs: PluginStartArgs + 'static, Instance: PluginInstance + 'static> P
names
);
let mut plugins = Vec::new();
for plugin in self.declared_plugins() {
for plugin in self.declared_plugins_iter() {
let name = unsafe { keyexpr::from_str_unchecked(plugin.name()) };
if names.includes(name) {
let status = PluginStatusRec::new(plugin.as_status());
Expand Down
12 changes: 6 additions & 6 deletions plugins/zenoh-plugin-trait/src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub enum PluginState {
#[derive(Copy, Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize, PartialOrd, Ord)]
pub enum PluginReportLevel {
#[default]
Normal,
Info,
Warning,
Error,
}
Expand Down Expand Up @@ -203,8 +203,8 @@ impl PluginReport {
self.level |= PluginReportLevel::Warning;
self.messages.push(warning.into());
}
pub fn add_message<S: Into<Cow<'static, str>>>(&mut self, message: S) {
self.level |= PluginReportLevel::Normal;
pub fn add_info<S: Into<Cow<'static, str>>>(&mut self, message: S) {
self.level |= PluginReportLevel::Info;
self.messages.push(message.into());
}
pub fn messages(&self) -> &[Cow<'static, str>] {
Expand All @@ -215,7 +215,7 @@ impl PluginReport {
pub trait PluginConditionSetter {
fn add_error(self, report: &mut PluginReport) -> Self;
fn add_warning(self, report: &mut PluginReport) -> Self;
fn add_message(self, report: &mut PluginReport) -> Self;
fn add_info(self, report: &mut PluginReport) -> Self;
}

impl<T, E: ToString> PluginConditionSetter for core::result::Result<T, E> {
Expand All @@ -231,9 +231,9 @@ impl<T, E: ToString> PluginConditionSetter for core::result::Result<T, E> {
}
self
}
fn add_message(self, report: &mut PluginReport) -> Self {
fn add_info(self, report: &mut PluginReport) -> Self {
if let Err(e) = &self {
report.add_message(e.to_string());
report.add_info(e.to_string());
}
self
}
Expand Down
6 changes: 3 additions & 3 deletions zenoh/src/net/runtime/adminspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ impl AdminSpace {
);

let mut active_plugins = plugins_mgr
.started_plugins()
.started_plugins_iter()
.map(|rec| (rec.name().to_string(), rec.path().to_string()))
.collect::<HashMap<_, _>>();

Expand Down Expand Up @@ -458,7 +458,7 @@ fn router_data(context: &AdminContext, query: Query) {
let plugins: serde_json::Value = {
let plugins_mgr = zlock!(context.plugins_mgr);
plugins_mgr
.started_plugins()
.started_plugins_iter()
.map(|rec| (rec.name(), json!({ "path": rec.path() })))
.collect()
};
Expand Down Expand Up @@ -681,7 +681,7 @@ fn plugins_status(context: &AdminContext, query: Query) {
let guard = zlock!(context.plugins_mgr);
let mut root_key = format!("@/router/{}/status/plugins/", &context.zid_str);

for plugin in guard.started_plugins() {
for plugin in guard.started_plugins_iter() {
with_extended_string(&mut root_key, &[plugin.name()], |plugin_key| {
// TODO: response to "__version__", this need not to be implemented by each plugin
with_extended_string(plugin_key, &["/__path__"], |plugin_path_key| {
Expand Down
2 changes: 1 addition & 1 deletion zenohd/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ fn main() {
}
};

for plugin in plugin_mgr.loaded_plugins_mut() {
for plugin in plugin_mgr.loaded_plugins_iter_mut() {
let required = required_plugins.contains(plugin.name());
log::info!(
"Starting {req} plugin \"{name}\"",
Expand Down

0 comments on commit ff0ab93

Please sign in to comment.