From 294c4e150752d92b379ca134567ff9dcb317060c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Ant=C3=B4nio=20Cardoso?= Date: Tue, 17 Sep 2024 01:59:18 -0300 Subject: [PATCH] src: stats: Add hub messages stats to the protocol --- src/stats/actor.rs | 11 +++++++++++ src/stats/protocol.rs | 5 +++++ 2 files changed, 16 insertions(+) diff --git a/src/stats/actor.rs b/src/stats/actor.rs index a182f2e5..a8f8aea7 100644 --- a/src/stats/actor.rs +++ b/src/stats/actor.rs @@ -113,6 +113,10 @@ impl StatsActor { let result = self.hub_stats().await; let _ = response.send(result); } + StatsCommand::GetHubMessagesStats { response } => { + let result = self.hub_messages_stats().await; + let _ = response.send(result); + } } } @@ -153,6 +157,13 @@ impl StatsActor { Ok(hub_stats) } + #[instrument(level = "debug", skip(self))] + async fn hub_messages_stats(&self) -> Result { + let hub_messages_stats = self.hub_messages_stats.read().await.clone(); + + Ok(hub_messages_stats) + } + #[instrument(level = "debug", skip(self))] async fn drivers_stats(&mut self) -> Result { let drivers_stats = self.drivers_stats.read().await.clone(); diff --git a/src/stats/protocol.rs b/src/stats/protocol.rs index 62422d4a..b020df28 100644 --- a/src/stats/protocol.rs +++ b/src/stats/protocol.rs @@ -3,6 +3,8 @@ use tokio::sync::oneshot; use crate::stats::{DriversStats, StatsInner}; +use super::messages::HubMessagesStats; + pub enum StatsCommand { SetPeriod { period: tokio::time::Duration, @@ -17,4 +19,7 @@ pub enum StatsCommand { GetHubStats { response: oneshot::Sender>, }, + GetHubMessagesStats { + response: oneshot::Sender>, + }, }