From c976e1c57174643bbd3a833a45b19276ebdb0737 Mon Sep 17 00:00:00 2001 From: Michael Ilyin Date: Tue, 5 Dec 2023 14:59:25 +0000 Subject: [PATCH 1/5] config for testing plugins, error s logging --- DEFAULT_CONFIG.json5 | 24 ++++++++-------- plugin_test_config.json5 | 28 +++++++++++++++++++ .../zenoh-plugin-storage-manager/src/lib.rs | 12 ++++---- 3 files changed, 46 insertions(+), 18 deletions(-) create mode 100644 plugin_test_config.json5 diff --git a/DEFAULT_CONFIG.json5 b/DEFAULT_CONFIG.json5 index fd3d08d942..4321c3fcc7 100644 --- a/DEFAULT_CONFIG.json5 +++ b/DEFAULT_CONFIG.json5 @@ -407,17 +407,17 @@ // }, /// Plugin configuration example using `__config__` property - plugins: { - rest: { - __config__: "./plugins/zenoh-plugin-rest/config.json5", - }, - storage_manager: { - __config__: "./plugins/zenoh-plugin-storage-manager/config.json5", - }, - not_found: { - }, - example: { - }, - }, + // plugins: { + // rest: { + // __config__: "./plugins/zenoh-plugin-rest/config.json5", + // }, + // storage_manager: { + // __config__: "./plugins/zenoh-plugin-storage-manager/config.json5", + // }, + // not_found: { + // }, + // example: { + // }, + // }, } diff --git a/plugin_test_config.json5 b/plugin_test_config.json5 new file mode 100644 index 0000000000..3c4b98c06b --- /dev/null +++ b/plugin_test_config.json5 @@ -0,0 +1,28 @@ +{ + "plugins": { + "rest": { + "http_port": 8080, + }, + "storage_manager": { + "volumes": { + "example": { + "__path__": ["target/debug/libzenoh_backend_example.so","target/debug/libzenoh_backend_example.dylib"], + } + }, + "storages": { + "memory": { + "volume": "memory", + "key_expr": "demo/memory/**" + }, + "example": { + "volume": "example", + "key_expr": "demo/example/**" + }, + } + }, + "not_found": { + }, + "example": { + }, + } +} diff --git a/plugins/zenoh-plugin-storage-manager/src/lib.rs b/plugins/zenoh-plugin-storage-manager/src/lib.rs index d568037e18..880b794a68 100644 --- a/plugins/zenoh-plugin-storage-manager/src/lib.rs +++ b/plugins/zenoh-plugin-storage-manager/src/lib.rs @@ -127,20 +127,20 @@ impl StorageRuntimeInner { storages: Default::default(), plugins_manager, }; - let _ = new_self.spawn_volume(VolumeConfig { + new_self.spawn_volume(VolumeConfig { name: MEMORY_BACKEND_NAME.into(), backend: None, paths: None, required: false, rest: Default::default(), - }); + }).map_or_else(|e| log::error!("Cannot spawn memory volume: {}", e), |_| ()); for volume in volumes { - let _ = new_self - .spawn_volume(volume); + new_self + .spawn_volume(volume).map_or_else(|e| log::error!("Cannot spawn volume: {}", e), |_| ()); } for storage in storages { - let _ = new_self - .spawn_storage(storage); + new_self + .spawn_storage(storage).map_or_else(|e| log::error!("Cannot spawn storage: {}", e), |_| ()); } Ok(new_self) } From 03d426dc50da4303b075c0f79d080799cfc38da0 Mon Sep 17 00:00:00 2001 From: Michael Ilyin Date: Tue, 5 Dec 2023 15:16:49 +0000 Subject: [PATCH 2/5] no_mangle in example --- plugins/example-storage-plugin/Cargo.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/example-storage-plugin/Cargo.toml b/plugins/example-storage-plugin/Cargo.toml index 37465b5f87..b9d56615d4 100644 --- a/plugins/example-storage-plugin/Cargo.toml +++ b/plugins/example-storage-plugin/Cargo.toml @@ -18,6 +18,10 @@ version = { workspace = true } authors = { workspace = true } edition = { workspace = true } +[features] +default = ["no_mangle"] +no_mangle = [] + [lib] name = "zenoh_backend_example" # This crate type will make `cargo` output a dynamic library instead of a rust static library From 3d7c61403865ea2eae646db9c2c2b6a551c328cb Mon Sep 17 00:00:00 2001 From: Michael Ilyin Date: Tue, 5 Dec 2023 15:24:23 +0000 Subject: [PATCH 3/5] compile fixes --- plugins/zenoh-plugin-storage-manager/src/lib.rs | 1 - zenoh/src/net/routing/face.rs | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/zenoh-plugin-storage-manager/src/lib.rs b/plugins/zenoh-plugin-storage-manager/src/lib.rs index 880b794a68..928aaeac18 100644 --- a/plugins/zenoh-plugin-storage-manager/src/lib.rs +++ b/plugins/zenoh-plugin-storage-manager/src/lib.rs @@ -38,7 +38,6 @@ use zenoh_backend_traits::config::VolumeConfig; use zenoh_backend_traits::VolumePlugin; use zenoh_core::zlock; use zenoh_plugin_trait::Plugin; -use zenoh_plugin_trait::PluginConditionSetter; use zenoh_plugin_trait::PluginControl; use zenoh_plugin_trait::PluginReport; use zenoh_plugin_trait::PluginStatusRec; diff --git a/zenoh/src/net/routing/face.rs b/zenoh/src/net/routing/face.rs index 7616420ec8..90946527ee 100644 --- a/zenoh/src/net/routing/face.rs +++ b/zenoh/src/net/routing/face.rs @@ -81,7 +81,7 @@ impl FaceState { }) } - #[cfg(feature = "unstable")] + #[allow(dead_code)] #[inline] pub fn is_local(&self) -> bool { self.local From 536d808678e3bed0aaec39063b7d70978db8b6d0 Mon Sep 17 00:00:00 2001 From: Michael Ilyin Date: Tue, 5 Dec 2023 15:47:47 +0000 Subject: [PATCH 4/5] dds plugin tested --- plugin_test_config.json5 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugin_test_config.json5 b/plugin_test_config.json5 index 3c4b98c06b..e5575c905d 100644 --- a/plugin_test_config.json5 +++ b/plugin_test_config.json5 @@ -24,5 +24,8 @@ }, "example": { }, + "dds": { + "__path__": ["../zenoh-plugin-dds/target/debug/libzenoh_plugin_dds.so","../zenoh-plugin-dds/target/debug/libzenoh_plugin_dds.dylib"], + } } } From 296142b4c2fe647de413b7283b8c213c37f89bd2 Mon Sep 17 00:00:00 2001 From: Michael Ilyin Date: Tue, 5 Dec 2023 16:01:52 +0000 Subject: [PATCH 5/5] cargo fmt --- plugins/zenoh-backend-traits/src/lib.rs | 2 +- .../zenoh-plugin-storage-manager/src/lib.rs | 23 +++++++++++-------- plugins/zenoh-plugin-trait/src/lib.rs | 6 ++--- plugins/zenoh-plugin-trait/src/vtable.rs | 2 +- zenoh/src/net/runtime/adminspace.rs | 6 ++--- zenoh/src/plugins/sealed.rs | 5 ++-- 6 files changed, 23 insertions(+), 21 deletions(-) diff --git a/plugins/zenoh-backend-traits/src/lib.rs b/plugins/zenoh-backend-traits/src/lib.rs index b7b7c9220a..ec42a5b581 100644 --- a/plugins/zenoh-backend-traits/src/lib.rs +++ b/plugins/zenoh-backend-traits/src/lib.rs @@ -15,7 +15,7 @@ //! ⚠️ WARNING ⚠️ //! //! TODO: The example is outdated, rewrite it -//! +//! //! This crate should be considered unstable, as in we might change the APIs anytime. //! //! This crate provides the traits to be implemented by a zenoh backend library: diff --git a/plugins/zenoh-plugin-storage-manager/src/lib.rs b/plugins/zenoh-plugin-storage-manager/src/lib.rs index 928aaeac18..41dd2ba627 100644 --- a/plugins/zenoh-plugin-storage-manager/src/lib.rs +++ b/plugins/zenoh-plugin-storage-manager/src/lib.rs @@ -114,7 +114,6 @@ impl StorageRuntimeInner { let plugins_manager = PluginsManager::dynamic(lib_loader.clone(), BACKEND_LIB_PREFIX) .declare_static_plugin::(); - let session = Arc::new(zenoh::init(runtime.clone()).res_sync()?); // After this moment result should be only Ok. Failure of loading of one voulme or storage should not affect others. @@ -126,20 +125,24 @@ impl StorageRuntimeInner { storages: Default::default(), plugins_manager, }; - new_self.spawn_volume(VolumeConfig { - name: MEMORY_BACKEND_NAME.into(), - backend: None, - paths: None, - required: false, - rest: Default::default(), - }).map_or_else(|e| log::error!("Cannot spawn memory volume: {}", e), |_| ()); + new_self + .spawn_volume(VolumeConfig { + name: MEMORY_BACKEND_NAME.into(), + backend: None, + paths: None, + required: false, + rest: Default::default(), + }) + .map_or_else(|e| log::error!("Cannot spawn memory volume: {}", e), |_| ()); for volume in volumes { new_self - .spawn_volume(volume).map_or_else(|e| log::error!("Cannot spawn volume: {}", e), |_| ()); + .spawn_volume(volume) + .map_or_else(|e| log::error!("Cannot spawn volume: {}", e), |_| ()); } for storage in storages { new_self - .spawn_storage(storage).map_or_else(|e| log::error!("Cannot spawn storage: {}", e), |_| ()); + .spawn_storage(storage) + .map_or_else(|e| log::error!("Cannot spawn storage: {}", e), |_| ()); } Ok(new_self) } diff --git a/plugins/zenoh-plugin-trait/src/lib.rs b/plugins/zenoh-plugin-trait/src/lib.rs index 70409afb05..b3e91c2395 100644 --- a/plugins/zenoh-plugin-trait/src/lib.rs +++ b/plugins/zenoh-plugin-trait/src/lib.rs @@ -31,7 +31,5 @@ pub use plugin::{ pub use vtable::{Compatibility, PluginLoaderVersion, PluginVTable, PLUGIN_LOADER_VERSION}; use zenoh_util::concat_enabled_features; -pub const FEATURES: &str = concat_enabled_features!( - prefix = "zenoh-plugin-trait", - features = ["default"] -); +pub const FEATURES: &str = + concat_enabled_features!(prefix = "zenoh-plugin-trait", features = ["default"]); diff --git a/plugins/zenoh-plugin-trait/src/vtable.rs b/plugins/zenoh-plugin-trait/src/vtable.rs index 2a883df31a..d4e51a3ade 100644 --- a/plugins/zenoh-plugin-trait/src/vtable.rs +++ b/plugins/zenoh-plugin-trait/src/vtable.rs @@ -228,4 +228,4 @@ macro_rules! declare_plugin { $crate::PluginVTable::new::<$ty>() } }; -} \ No newline at end of file +} diff --git a/zenoh/src/net/runtime/adminspace.rs b/zenoh/src/net/runtime/adminspace.rs index 73604e0e81..dd7f3adc7a 100644 --- a/zenoh/src/net/runtime/adminspace.rs +++ b/zenoh/src/net/runtime/adminspace.rs @@ -21,15 +21,15 @@ use crate::value::Value; use async_std::task; use log::{error, trace}; use serde_json::json; -use zenoh_plugin_trait::{PluginControl, PluginStatus}; -use zenoh_protocol::core::key_expr::keyexpr; use std::collections::HashMap; use std::convert::TryFrom; use std::convert::TryInto; use std::sync::Arc; use std::sync::Mutex; use zenoh_buffers::buffer::SplitBuffer; -use zenoh_config::{ValidatedMap, ConfigValidator}; +use zenoh_config::{ConfigValidator, ValidatedMap}; +use zenoh_plugin_trait::{PluginControl, PluginStatus}; +use zenoh_protocol::core::key_expr::keyexpr; use zenoh_protocol::{ core::{key_expr::OwnedKeyExpr, ExprId, KnownEncoding, WireExpr, ZenohId, EMPTY_EXPR_ID}, network::{ diff --git a/zenoh/src/plugins/sealed.rs b/zenoh/src/plugins/sealed.rs index 573c18ab60..7e790270e0 100644 --- a/zenoh/src/plugins/sealed.rs +++ b/zenoh/src/plugins/sealed.rs @@ -19,13 +19,14 @@ pub use crate::runtime::Runtime; pub use crate::Result as ZResult; use zenoh_core::zconfigurable; -use zenoh_plugin_trait::{Plugin, PluginControl, PluginInstance, PluginReport, PluginStatusRec, PluginStructVersion}; +use zenoh_plugin_trait::{ + Plugin, PluginControl, PluginInstance, PluginReport, PluginStatusRec, PluginStructVersion, +}; use zenoh_protocol::core::key_expr::keyexpr; zconfigurable! { pub static ref PLUGIN_PREFIX: String = "zenoh_plugin_".to_string(); } - /// Zenoh plugins should implement this trait to ensure type-safety, even if the starting arguments and expected plugin types change in a future release. pub trait ZenohPlugin: Plugin {}