diff options
author | Matthias Beyer <matthias.beyer@ifm.com> | 2022-03-22 09:38:42 +0100 |
---|---|---|
committer | Matthias Beyer <matthias.beyer@ifm.com> | 2022-03-23 11:43:38 +0100 |
commit | 571e56143b8b340ddf9f109d25e1076b6e23aaaa (patch) | |
tree | dd432903455827621501e7522ac2f8fe7fbac9d5 /tedge | |
parent | db313c8151c445831b71ed186a46d334e29db8ca (diff) |
Adapt tedge-cli to new core interface
Signed-off-by: Matthias Beyer <matthias.beyer@ifm.com>
Diffstat (limited to 'tedge')
-rw-r--r-- | tedge/Cargo.toml | 1 | ||||
-rw-r--r-- | tedge/src/main.rs | 21 |
2 files changed, 14 insertions, 8 deletions
diff --git a/tedge/Cargo.toml b/tedge/Cargo.toml index b6d80a75..e3000c15 100644 --- a/tedge/Cargo.toml +++ b/tedge/Cargo.toml @@ -17,6 +17,7 @@ console-subscriber = { version = "0.1", optional = true } tedge_api = { path = "../crates/core/tedge_api" } tedge_core = { path = "../crates/core/tedge_core" } +tedge_lib = { path = "../crates/core/tedge_lib" } env_logger = { version = "0.9", optional = true } diff --git a/tedge/src/main.rs b/tedge/src/main.rs index 7922f220..fe0d5fc6 100644 --- a/tedge/src/main.rs +++ b/tedge/src/main.rs @@ -3,13 +3,13 @@ use std::collections::HashSet; use clap::Parser; use tedge_api::PluginBuilder; -use tedge_core::configuration::TedgeConfiguration; use tedge_core::TedgeApplication; use tedge_core::TedgeApplicationCancelSender; +use tedge_core::configuration::TedgeConfiguration; +use tedge_lib::measurement::Measurement; use tracing::debug; use tracing::error; use tracing::info; -use tracing::trace; mod cli; mod logging; @@ -40,14 +40,15 @@ async fn main() -> anyhow::Result<()> { info!("Building application"); macro_rules! register_plugin { - ($app:ident, $cfg:tt, $pluginbuilder:expr) => {{ + ($app:ident, $cfg:tt, $pluginbuilder:ty, $pbinstance:expr) => {{ cfg_if::cfg_if! { if #[cfg(feature = $cfg)] { - info!("Registering plugin builder for plugins of type {}", $pluginbuilder.kind_name()); - if !plugin_kinds.insert($pluginbuilder.kind_name()) { - anyhow::bail!("Plugin kind '{}' was already registered, cannot register!", $pluginbuilder.kind_name()) + let kind_name: &'static str = <$pluginbuilder as PluginBuilder<tedge_core::PluginDirectory>>::kind_name(); + info!("Registering plugin builder for plugins of type {}", kind_name); + if !plugin_kinds.insert(kind_name) { + anyhow::bail!("Plugin kind '{}' was already registered, cannot register!", kind_name) } - $app.with_plugin_builder(Box::new($pluginbuilder))? + $app.with_plugin_builder($pbinstance)? } else { trace!("Not supporting plugins of type {}", std::stringify!($pluginbuilder)); $app @@ -59,21 +60,25 @@ async fn main() -> anyhow::Result<()> { let application = register_plugin!( application, "builtin_plugin_avg", + plugin_avg::AvgPluginBuilder, plugin_avg::AvgPluginBuilder ); let application = register_plugin!( application, "builtin_plugin_log", - plugin_log::LogPluginBuilder + plugin_log::LogPluginBuilder<(Measurement,)>, + plugin_log::LogPluginBuilder::<(Measurement,)>::new() ); let application = register_plugin!( application, "builtin_plugin_sysstat", + plugin_sysstat::SysStatPluginBuilder, plugin_sysstat::SysStatPluginBuilder ); let application = register_plugin!( application, "builtin_plugin_inotify", + plugin_inotify::InotifyPluginBuilder, plugin_inotify::InotifyPluginBuilder ); |