diff --git a/flake.lock b/flake.lock index 2b7c91e..6c815eb 100644 --- a/flake.lock +++ b/flake.lock @@ -5,11 +5,11 @@ "nixpkgs-lib": "nixpkgs-lib" }, "locked": { - "lastModified": 1725234343, - "narHash": "sha256-+ebgonl3NbiKD2UD0x4BszCZQ6sTfL4xioaM49o5B3Y=", + "lastModified": 1726153070, + "narHash": "sha256-HO4zgY0ekfwO5bX0QH/3kJ/h4KvUDFZg8YpkNwIbg1U=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "567b938d64d4b4112ee253b9274472dc3a346eb6", + "rev": "bcef6817a8b2aa20a5a6dbb19b43e63c5bf8619a", "type": "github" }, "original": { @@ -20,11 +20,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1725103162, - "narHash": "sha256-Ym04C5+qovuQDYL/rKWSR+WESseQBbNAe5DsXNx5trY=", + "lastModified": 1726243404, + "narHash": "sha256-sjiGsMh+1cWXb53Tecsm4skyFNag33GPbVgCdfj3n9I=", "owner": "nixos", "repo": "nixpkgs", - "rev": "12228ff1752d7b7624a54e9c1af4b222b3c1073b", + "rev": "345c263f2f53a3710abe117f28a5cb86d0ba4059", "type": "github" }, "original": { diff --git a/justfile b/justfile index 3141d18..c613449 100644 --- a/justfile +++ b/justfile @@ -10,10 +10,10 @@ run *ARGS: cargo run {{ARGS}} head-node *ARGS: - cargo run --bin head-node + cargo run --bin head-node --features="head" worker-node *ARGS: - cargo run --bin worker-node + cargo run --bin worker-node --features="worker" # Run 'cargo watch' to run the project (auto-recompiles) watch *ARGS: diff --git a/yotei-nodes/src/head.rs b/yotei-nodes/src/head.rs index 118801e..63fe336 100644 --- a/yotei-nodes/src/head.rs +++ b/yotei-nodes/src/head.rs @@ -2,7 +2,7 @@ mod util; use std::{collections::HashMap, sync::RwLock}; -use crate::config::CONFIG; +use crate::util::config::CONFIG; use clap::{Parser, Subcommand}; use log::{debug, info}; use sched::AliveCheckRequest; @@ -62,9 +62,9 @@ async fn main() -> Result<(), Box> { } let addr = "[::1]:50051".parse()?; info!("Starting gRPC server on {}", addr); - let data = grpc::DataService::default(); - let auth = grpc::AuthService::default(); - let alive = grpc::AliveCheckService::default(); + let data = crate::util::grpc::DataService::default(); + let auth = crate::util::grpc::AuthService::default(); + let alive = crate::util::grpc::AliveCheckService::default(); let grpc_server = Server::builder() .add_service(sched::data_server::DataServer::new(data)) .add_service(sched::auth_server::AuthServer::new(auth)) diff --git a/yotei-nodes/src/util/grpc.rs b/yotei-nodes/src/util/grpc.rs index f734620..2707831 100644 --- a/yotei-nodes/src/util/grpc.rs +++ b/yotei-nodes/src/util/grpc.rs @@ -5,10 +5,13 @@ use crate::sched::{ }; use log::{debug, info}; +pub mod sched { + tonic::include_proto!("sched"); +} #[cfg(feature = "head")] -use crate::state::STATE; +use crate::util::state::STATE; #[derive(Debug, Default)] pub struct DataService {} diff --git a/yotei-nodes/src/util/state.rs b/yotei-nodes/src/util/state.rs index 6191671..948e841 100644 --- a/yotei-nodes/src/util/state.rs +++ b/yotei-nodes/src/util/state.rs @@ -1,13 +1,14 @@ +use std::{collections::HashMap, sync::RwLock }; + lazy_static::lazy_static! { pub static ref STATE: RwLock = RwLock::new(State { nodes: vec![], - tasks: HashMap::new(), + tasks: HashMap::new(), }); } pub struct Node { - pub id: String, pub specs: NodeSpecs, pub curr_job: Task, pub job_queue: JobQueue, diff --git a/yotei-nodes/src/worker.rs b/yotei-nodes/src/worker.rs index 9eb9172..873d9b2 100644 --- a/yotei-nodes/src/worker.rs +++ b/yotei-nodes/src/worker.rs @@ -2,10 +2,9 @@ use std::{ net::SocketAddr, sync::{atomic::AtomicBool, Arc}, }; -mod grpc; +mod util; -mod config; -use crate::config::CONFIG; +use crate::util::config::CONFIG; use log::{debug, error, info}; use sched::{DataRequest, LoginRequest, LogoutRequest};