Skip to content

Commit

Permalink
src: Propagate new structs names
Browse files Browse the repository at this point in the history
  • Loading branch information
joaoantoniocardoso committed Sep 16, 2024
1 parent 32d14b8 commit c9691cb
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/drivers/tcp/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::{
Driver, DriverInfo,
},
protocol::Protocol,
stats::driver::{AccumulatedDriverStatsProvider, AccumulatedDriverStats},
stats::driver::{AccumulatedDriverStats, AccumulatedDriverStatsProvider},
};

pub struct TcpClient {
Expand Down
2 changes: 1 addition & 1 deletion src/drivers/tcp/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::{
Driver, DriverInfo,
},
protocol::Protocol,
stats::driver::{AccumulatedDriverStatsProvider, AccumulatedDriverStats},
stats::driver::{AccumulatedDriverStats, AccumulatedDriverStatsProvider},
};

#[derive(Clone)]
Expand Down
2 changes: 1 addition & 1 deletion src/drivers/tlog/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use tracing::*;
use crate::{
drivers::{Driver, DriverInfo},
protocol::Protocol,
stats::driver::{AccumulatedDriverStatsProvider, AccumulatedDriverStats},
stats::driver::{AccumulatedDriverStats, AccumulatedDriverStatsProvider},
};

pub struct TlogReader {
Expand Down
2 changes: 1 addition & 1 deletion src/drivers/tlog/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use tracing::*;
use crate::{
drivers::{Driver, DriverInfo},
protocol::Protocol,
stats::driver::{AccumulatedDriverStatsProvider, AccumulatedDriverStats},
stats::driver::{AccumulatedDriverStats, AccumulatedDriverStatsProvider},
};

pub struct TlogWriter {
Expand Down
15 changes: 6 additions & 9 deletions src/hub/actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ use tracing::*;

use crate::{
drivers::{Driver, DriverInfo},
hub::HubCommand,
protocol::Protocol,
stats::driver::DriverStatsInfo,
stats::driver::AccumulatedDriverStats,
};

use super::protocol::HubCommand;

pub struct HubActor {
drivers: HashMap<u64, Arc<dyn Driver>>,
bcst_sender: broadcast::Sender<Arc<Protocol>>,
Expand Down Expand Up @@ -41,9 +40,9 @@ impl HubActor {
HubCommand::GetSender { response } => {
let _ = response.send(self.bcst_sender.clone());
}
HubCommand::GetStats { response } => {
let stats = self.get_stats().await;
let _ = response.send(stats);
HubCommand::GetDriversStats { response } => {
let drivers_stats = self.get_drivers_stats().await;
let _ = response.send(drivers_stats);
}
HubCommand::ResetAllStats { response } => {
let _ = response.send(self.reset_all_stats().await);
Expand All @@ -70,8 +69,6 @@ impl HubActor {
Self::heartbeat_task(bcst_sender, component_id, system_id, frequency)
});

});

Self {
drivers: HashMap::new(),
bcst_sender,
Expand Down Expand Up @@ -164,7 +161,7 @@ impl HubActor {
}

#[instrument(level = "debug", skip(self))]
pub async fn get_stats(&self) -> Vec<(String, DriverStatsInfo)> {
pub async fn get_drivers_stats(&self) -> Vec<(String, AccumulatedDriverStats)> {
let mut drivers_stats = Vec::with_capacity(self.drivers.len());
for (_id, driver) in self.drivers.iter() {
let stats = driver.stats().await;
Expand Down
12 changes: 6 additions & 6 deletions src/hub/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use tokio::sync::{broadcast, mpsc, oneshot, RwLock};
use crate::{
drivers::{Driver, DriverInfo},
protocol::Protocol,
stats::driver::DriverStatsInfo,
stats::driver::AccumulatedDriverStats,
};

use actor::HubActor;
Expand All @@ -21,7 +21,7 @@ use protocol::HubCommand;
#[derive(Clone)]
pub struct Hub {
sender: mpsc::Sender<HubCommand>,
task: Arc<Mutex<tokio::task::JoinHandle<()>>>,
_task: Arc<Mutex<tokio::task::JoinHandle<()>>>,
}

impl Hub {
Expand All @@ -33,8 +33,8 @@ impl Hub {
) -> Self {
let (sender, receiver) = mpsc::channel(32);
let hub = HubActor::new(buffer_size, component_id, system_id, frequency).await;
let task = Arc::new(Mutex::new(tokio::spawn(hub.start(receiver))));
Self { sender, task }
let _task = Arc::new(Mutex::new(tokio::spawn(hub.start(receiver))));
Self { sender, _task }
}

pub async fn add_driver(&self, driver: Arc<dyn Driver>) -> Result<u64> {
Expand Down Expand Up @@ -81,10 +81,10 @@ impl Hub {
Ok(res)
}

pub async fn stats(&self) -> Result<Vec<(String, DriverStatsInfo)>> {
pub async fn drivers_stats(&self) -> Result<Vec<(String, AccumulatedDriverStats)>> {
let (response_tx, response_rx) = oneshot::channel();
self.sender
.send(HubCommand::GetStats {
.send(HubCommand::GetDriversStats {
response: response_tx,
})
.await?;
Expand Down
6 changes: 3 additions & 3 deletions src/hub/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use tokio::sync::{broadcast, oneshot};
use crate::{
drivers::{Driver, DriverInfo},
protocol::Protocol,
stats::driver::DriverStatsInfo,
stats::driver::AccumulatedDriverStats,
};

pub enum HubCommand {
Expand All @@ -24,8 +24,8 @@ pub enum HubCommand {
GetSender {
response: oneshot::Sender<broadcast::Sender<Arc<Protocol>>>,
},
GetStats {
response: oneshot::Sender<Vec<(String, DriverStatsInfo)>>,
GetDriversStats {
response: oneshot::Sender<Vec<(String, AccumulatedDriverStats)>>,
},
ResetAllStats {
response: oneshot::Sender<Result<()>>,
Expand Down

0 comments on commit c9691cb

Please sign in to comment.