Skip to content

Commit

Permalink
src: stats: Add hub messages stats to the protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
joaoantoniocardoso committed Sep 17, 2024
1 parent 518e999 commit 294c4e1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/stats/actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}

Expand Down Expand Up @@ -153,6 +157,13 @@ impl StatsActor {
Ok(hub_stats)
}

#[instrument(level = "debug", skip(self))]
async fn hub_messages_stats(&self) -> Result<HubMessagesStats> {
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<DriversStats> {
let drivers_stats = self.drivers_stats.read().await.clone();
Expand Down
5 changes: 5 additions & 0 deletions src/stats/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -17,4 +19,7 @@ pub enum StatsCommand {
GetHubStats {
response: oneshot::Sender<Result<StatsInner>>,
},
GetHubMessagesStats {
response: oneshot::Sender<Result<HubMessagesStats>>,
},
}

0 comments on commit 294c4e1

Please sign in to comment.