use shared constant for message interval

This commit is contained in:
csehviktor
2025-07-06 02:27:39 +02:00
parent d6c82af613
commit 158369ffb3
2 changed files with 3 additions and 4 deletions

View File

@@ -1,3 +1,4 @@
use common::MQTT_SEND_INTERVAL;
use collector::Collector; use collector::Collector;
use std::time::Duration; use std::time::Duration;
use mqtt::MqttHandle; use mqtt::MqttHandle;
@@ -19,9 +20,6 @@ struct Args {
#[arg(long, default_value_t = 1883)] #[arg(long, default_value_t = 1883)]
port: u16, port: u16,
#[arg(long, short='i', default_value_t = 5)]
interval: u64,
} }
#[tokio::main] #[tokio::main]
@@ -37,6 +35,6 @@ async fn main() -> anyhow::Result<()> {
let metrics = collector.collect_all(); let metrics = collector.collect_all();
client.send_metrics(metrics).await?; client.send_metrics(metrics).await?;
thread::sleep(Duration::from_secs(args.interval)); thread::sleep(Duration::from_secs(MQTT_SEND_INTERVAL));
} }
} }

View File

@@ -6,6 +6,7 @@ use crate::metrics::Metrics;
pub mod metrics; pub mod metrics;
pub const MQTT_TOPIC: &str = "system/metrics"; pub const MQTT_TOPIC: &str = "system/metrics";
pub const MQTT_SEND_INTERVAL: u64 = 5;
#[derive(Debug, Serialize, Deserialize)] #[derive(Debug, Serialize, Deserialize)]
pub struct StatusMessage<'a> { pub struct StatusMessage<'a> {