Actually run all the components in parallel threads

I have much to learn about async Rust, but the gist of it is that running try_join
on a bunch of futures makes it run them in one task which is not at all what I want
because all the components here are separate from each other. Apparently to make it
spawn separate tasks, you need to use tokio::spawn. You live and learn.

Ideally of course these should be separate processes entirely, but for now I'm
far too lazy to deal with that
This commit is contained in:
Aleksei Voronov 2023-11-29 11:24:55 +01:00
parent 635e8506c6
commit 51b5d6de71
3 changed files with 6 additions and 6 deletions

View File

@ -54,10 +54,10 @@ async fn main() -> Result<()> {
info!("Starting everything up"); info!("Starting everything up");
tokio::try_join!( let _ = tokio::try_join!(
post_indexer.start(), tokio::spawn(post_indexer.start()),
profile_classifier.start(), tokio::spawn(profile_classifier.start()),
feed_server.serve(), tokio::spawn(feed_server.serve()),
)?; )?;
Ok(()) Ok(())

View File

@ -34,7 +34,7 @@ impl PostIndexer {
} }
impl PostIndexer { impl PostIndexer {
pub async fn start(&self) -> Result<()> { pub async fn start(self) -> Result<()> {
info!("Starting"); info!("Starting");
loop { loop {

View File

@ -23,7 +23,7 @@ impl ProfileClassifier {
} }
} }
pub async fn start(&self) -> Result<()> { pub async fn start(self) -> Result<()> {
info!("Starting"); info!("Starting");
loop { loop {