RircdState::run()

This commit is contained in:
some body 2021-09-16 15:07:56 -05:00
parent e6e4a3df79
commit eb497a5468
1 changed files with 12 additions and 6 deletions

View File

@ -1,5 +1,6 @@
use eyre::Result; use eyre::Result;
use async_trait::async_trait; use async_trait::async_trait;
use tokio::task::JoinHandle;
use std::time::Instant; use std::time::Instant;
use std::sync::Arc; use std::sync::Arc;
use tokio::sync::oneshot; use tokio::sync::oneshot;
@ -38,14 +39,19 @@ impl RircdState {
self.endpoints.iter().filter(|ep| ep.is_active()).for_each(|endpoint| { self.endpoints.iter().filter(|ep| ep.is_active()).for_each(|endpoint| {
let endpoint_name = endpoint.name(); let endpoint_name = endpoint.name();
let (success_status_send,success_status_recv) = oneshot::channel::<Result<()>>(); let (success_status_send,success_status_recv) = oneshot::channel::<Result<()>>();
tokio::spawn(endpoint.listen(success_status_send)); tokio::spawn(endpoint.clone().listen(success_status_send));
//TODO color err msg //TODO color err msg
println!("starting {} | {}", endpoint_name, //TODO paralelize and sync at the end
match success_status_recv.await { tokio::task::spawn_local(async move {
Ok(_) => format!("SUCCEEDED |"), println!("starting {} | {}", endpoint_name,
Err(e) => format!("FAILED| <{}>", e), match success_status_recv.await {
}); Ok(_) => format!("SUCCEEDED |"),
Err(e) => format!("FAILED| <{}>", e),
});
});
}); });
Ok(()) Ok(())
} }
} }