summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <matthias.beyer@ifm.com>2022-05-19 16:36:59 +0200
committerMatthias Beyer <matthias.beyer@ifm.com>2022-05-23 12:17:59 +0200
commit15b69f5b34b18d8ab1a8c5d9389b3c22c4ce043d (patch)
tree61c53686e288669fc4c2de3bdf0da69e4e09e679
parent0e04a3ac9f17f112105214c2944bb134ed90f19c (diff)
Derive tedge_api::Config for configuration types
Signed-off-by: Matthias Beyer <matthias.beyer@ifm.com>
-rw-r--r--plugins/plugin_sysstat/src/config.rs30
1 files changed, 15 insertions, 15 deletions
diff --git a/plugins/plugin_sysstat/src/config.rs b/plugins/plugin_sysstat/src/config.rs
index a57e7760..66e8d1c0 100644
--- a/plugins/plugin_sysstat/src/config.rs
+++ b/plugins/plugin_sysstat/src/config.rs
@@ -1,9 +1,9 @@
use std::collections::HashMap;
-use tedge_lib::config::OneOrMany;
use tedge_lib::config::Address;
+use tedge_lib::config::OneOrMany;
-#[derive(serde::Deserialize, Debug)]
+#[derive(serde::Deserialize, Debug, tedge_api::Config)]
pub struct SysStatConfig {
pub(crate) memory: Option<MemoryConfig>,
pub(crate) network: Option<NetworkConfig>,
@@ -13,7 +13,7 @@ pub struct SysStatConfig {
pub(crate) process: Option<ProcessConfig>,
}
-#[derive(serde::Deserialize, Debug)]
+#[derive(serde::Deserialize, Debug, tedge_api::Config)]
pub struct BaseConfig {
send_to: OneOrMany<Address>,
interval_ms: std::num::NonZeroU64,
@@ -24,7 +24,7 @@ pub trait HasBaseConfig {
fn interval_ms(&self) -> std::num::NonZeroU64;
}
-#[derive(serde::Deserialize, Debug)]
+#[derive(serde::Deserialize, Debug, tedge_api::Config)]
pub struct MemoryConfig {
#[serde(flatten)]
base: BaseConfig,
@@ -142,7 +142,7 @@ impl HasBaseConfig for MemoryConfig {
}
}
-#[derive(serde::Deserialize, Debug)]
+#[derive(serde::Deserialize, Debug, tedge_api::Config)]
pub struct NetworkConfig {
#[serde(flatten)]
base: BaseConfig,
@@ -154,7 +154,7 @@ pub struct NetworkConfig {
pub(crate) by_name: HashMap<String, NetworkStatConfig>,
}
-#[derive(serde::Deserialize, Clone, Debug)]
+#[derive(serde::Deserialize, Clone, Debug, tedge_api::Config)]
pub struct AllNetworkStatConfig {
pub(crate) enable: bool,
@@ -162,7 +162,7 @@ pub struct AllNetworkStatConfig {
pub(crate) config: NetworkStatConfig,
}
-#[derive(serde::Deserialize, Clone, Debug)]
+#[derive(serde::Deserialize, Clone, Debug, tedge_api::Config)]
pub struct NetworkStatConfig {
/// Enable to report the "received" measurement
pub(crate) received: bool,
@@ -354,7 +354,7 @@ impl HasBaseConfig for NetworkConfig {
}
}
-#[derive(serde::Deserialize, Debug)]
+#[derive(serde::Deserialize, Debug, tedge_api::Config)]
pub struct CpuConfig {
#[serde(flatten)]
base: BaseConfig,
@@ -408,7 +408,7 @@ fn physical_core_count_name_default() -> String {
"physical_core_count".to_string()
}
-#[derive(serde::Deserialize, Clone, Debug)]
+#[derive(serde::Deserialize, Clone, Debug, tedge_api::Config)]
pub struct ProcessorInfoConfig {
/// Enable reporting this stat
pub(crate) enable: bool,
@@ -494,7 +494,7 @@ fn brand_default_name() -> String {
"brand".to_string()
}
-#[derive(serde::Deserialize, Clone, Debug)]
+#[derive(serde::Deserialize, Clone, Debug, tedge_api::Config)]
pub struct PhysicalCoreCountConfig {
pub(crate) enable: bool,
}
@@ -509,7 +509,7 @@ impl HasBaseConfig for CpuConfig {
}
}
-#[derive(serde::Deserialize, Debug)]
+#[derive(serde::Deserialize, Debug, tedge_api::Config)]
pub struct DiskUsageConfig {
#[serde(flatten)]
base: BaseConfig,
@@ -525,7 +525,7 @@ impl HasBaseConfig for DiskUsageConfig {
}
}
-#[derive(serde::Deserialize, Debug)]
+#[derive(serde::Deserialize, Debug, tedge_api::Config)]
pub struct LoadConfig {
#[serde(flatten)]
base: BaseConfig,
@@ -541,7 +541,7 @@ impl HasBaseConfig for LoadConfig {
}
}
-#[derive(serde::Deserialize, Debug)]
+#[derive(serde::Deserialize, Debug, tedge_api::Config)]
pub struct ProcessConfig {
#[serde(flatten)]
base: BaseConfig,
@@ -550,7 +550,7 @@ pub struct ProcessConfig {
pub(crate) by_name: HashMap<String, ProcessStatConfig>,
}
-#[derive(serde::Deserialize, Clone, Debug)]
+#[derive(serde::Deserialize, Clone, Debug, tedge_api::Config)]
pub struct AllProcessConfig {
/// Report stats for all processes
/// This automatically disables the "by_name" process reporting
@@ -560,7 +560,7 @@ pub struct AllProcessConfig {
pub(crate) config: ProcessStatConfig,
}
-#[derive(serde::Deserialize, Clone, Debug)]
+#[derive(serde::Deserialize, Clone, Debug, tedge_api::Config)]
pub struct ProcessStatConfig {
pub(crate) cmd: bool,
pub(crate) cwd: bool,