async fn start_children(&mut self) -> ActorResult<Vec<()>> {
use futures::stream::FuturesUnordered;
use futures::StreamExt;
let children = FuturesUnordered::new();
children.push(call!(self.build_manager_pid.start_children()));
children.push(call!(self.app_manager_pid.start_children()));
let ran: Vec<_> = children.collect().await;
let filtered: Vec<()> = ran.into_iter().flatten().flatten().collect();
Produces::ok(filtered)
}
Child actor also has children of its own
//BuildManager
pub async fn start_children(&self) -> ActorResult<Vec<()>> {
use futures::stream::FuturesUnordered;
info!("Starting build manager");
let bm_worker = spawn_actor(BuildMessageWorker::new(self).await);
let incoming_worker = spawn_actor(IncomingMessageWorker::new(self).await);
let children = FuturesUnordered::new();
children.push(call!(bm_worker.listen()));
children.push(call!(incoming_worker.listen()));
let ran: Vec<ActorCallResult<()>> = children.collect().await;
let filtered = ran.into_iter().filter_map(Result::ok).collect();
Produces::ok(filtered)
}
Hey here is how I'm exploring it right now, let me know what you think.
Main function, supervision tree root:
Starts children on startup
Root start children function
Child actor also has children of its own