Start reimplementing worker
This commit is contained in:
parent
22efa5bfc9
commit
81328fcf04
2 changed files with 3 additions and 141 deletions
|
|
@ -1,16 +1,6 @@
|
|||
mod coordinator;
|
||||
mod run;
|
||||
mod server;
|
||||
mod tree;
|
||||
use tracing::error;
|
||||
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use tokio::task::JoinSet;
|
||||
use tracing::{debug, error};
|
||||
|
||||
use crate::config::{Config, WorkerServerConfig};
|
||||
|
||||
use self::{coordinator::Coordinator, server::Server};
|
||||
use crate::config::Config;
|
||||
|
||||
pub struct Worker {
|
||||
config: &'static Config,
|
||||
|
|
@ -27,30 +17,6 @@ impl Worker {
|
|||
return;
|
||||
}
|
||||
|
||||
let coordinator = Arc::new(Mutex::new(Coordinator::new()));
|
||||
|
||||
let mut tasks = JoinSet::new();
|
||||
for (name, server_config) in self.config.worker_servers.iter() {
|
||||
debug!("Launching task for server {name}");
|
||||
let mut server = Server::new(
|
||||
name.clone(),
|
||||
self.config,
|
||||
server_config,
|
||||
coordinator.clone(),
|
||||
);
|
||||
tasks.spawn(async move { server.run().await });
|
||||
}
|
||||
|
||||
while tasks.join_next().await.is_some() {}
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn launch_standalone_server_task(
|
||||
config: &'static Config,
|
||||
server_name: String,
|
||||
server_config: &'static WorkerServerConfig,
|
||||
) {
|
||||
let coordinator = Arc::new(Mutex::new(Coordinator::new()));
|
||||
let mut server = Server::new(server_name, config, server_config, coordinator);
|
||||
tokio::task::spawn(async move { server.run().await });
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue