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 async_trait::async_trait;
use tokio::task::JoinHandle;
use std::time::Instant;
use std::sync::Arc;
use tokio::sync::oneshot;
@ -38,14 +39,19 @@ impl RircdState {
self.endpoints.iter().filter(|ep| ep.is_active()).for_each(|endpoint| {
let endpoint_name = endpoint.name();
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
println!("starting {} | {}", endpoint_name,
match success_status_recv.await {
Ok(_) => format!("SUCCEEDED |"),
Err(e) => format!("FAILED| <{}>", e),
});
//TODO paralelize and sync at the end
tokio::task::spawn_local(async move {
println!("starting {} | {}", endpoint_name,
match success_status_recv.await {
Ok(_) => format!("SUCCEEDED |"),
Err(e) => format!("FAILED| <{}>", e),
});
});
});
Ok(())
}
}