mod config; mod grpc; use std::collections::HashMap; use crate::config::CONFIG; use clap::{Parser, Subcommand}; use log::{debug, info}; use tonic::transport::Server; // Import generated protobuf mod sched { tonic::include_proto!("sched"); // pub(crate) const FILE_DESCRIPTOR_SET: FileDescriptorSet = // tonic::include_file_descriptor_set!("protocol_descriptor").into(); } struct Node { id: String, specs: NodeSpecs, curr_job: Job, job_queue: JobQueue, } struct Job { id: uuid::Uuid, data: Vec, } struct JobQueue { jobs: Vec, size: u128, } struct NodeSpecs { threads: u64, mem: u64, net_speed: f64, } struct State { nodes: Vec, delegation_efficiency: f32, tasks: HashMap, } #[derive(Parser)] #[command(author, version, about)] #[command(propagate_version = true)] struct Cli { #[command(subcommand)] command: Option, #[arg(short, long)] /// Optional path to config file config_file: Option, } #[derive(Subcommand)] enum Commands { /// Starts uwusched Start { role: Option }, } fn get_type_of(_: &T) -> &'static str { std::any::type_name::() } #[tokio::main] async fn main() -> Result<(), Box> { std::env::set_var("RUST_LOG", CONFIG.log.level.clone()); pretty_env_logger::init(); use colorful::Color; use colorful::Colorful; use colorful::HSL; println!(" {}", "+-------------+".color(Color::LightBlue)); println!(" {}", "| 予 定 |".color(Color::LightPink1)); println!( " {}", "+-------------+".color(colorful::RGB::new(252, 252, 252)) ); println!(" {}", "YOTEI SCHEDULER".color(Color::LightPink1)); println!(" {}", " HEAD NODE \n".color(Color::LightBlue)); let cli = Cli::parse(); match &cli.command { Some(Commands::Start { role }) => { debug!("{:#?}", role) } None => {} } let addr = "[::1]:50051".parse()?; info!("Starting gRPC server on {}", addr); let data = grpc::DataService::default(); let auth = grpc::AuthService::default(); Server::builder() .add_service(sched::data_server::DataServer::new(data)) .add_service(sched::auth_server::AuthServer::new(auth)) .serve(addr) .await?; debug!("{:?}", CONFIG.node); Ok(()) }