diff --git a/Cargo.lock b/Cargo.lock index 8eb69c1..22ac164 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -290,7 +290,7 @@ dependencies = [ [[package]] name = "detee-shared" version = "0.1.0" -source = "git+ssh://git@gitea.detee.cloud/noormohammedb/detee-shared#42443b816299afb0da6493b35165f8ce7558d717" +source = "git+ssh://git@gitea.detee.cloud/noormohammedb/detee-shared?branch=stable_01#df3a4631dd919e0cb35f6238f91f262c999c93b8" dependencies = [ "base64", "prost", diff --git a/Cargo.toml b/Cargo.toml index d8513ec..373e0c8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ anyhow = "1.0.95" rand = "0.8.5" tokio-stream = "0.1.17" -detee-shared = { git = "ssh://git@gitea.detee.cloud/noormohammedb/detee-shared" } +detee-shared = { git = "ssh://git@gitea.detee.cloud/noormohammedb/detee-shared", branch = "stable_01" } # detee-shared = { path = "../detee-shared" } log = "0.4.25" serde = "1.0.217" diff --git a/src/grpc.rs b/src/grpc.rs index 1e656ab..bf0986e 100644 --- a/src/grpc.rs +++ b/src/grpc.rs @@ -1,13 +1,13 @@ +use anyhow::Result; use detee_shared::pb::brain::brain_app_daemon_client::BrainAppDaemonClient; +use detee_shared::pb::brain::daemon_message_app; use detee_shared::pb::brain::{ AppContract, BrainMessageApp, DaemonMessageApp, Pubkey, RegisterAppNodeReq, }; - -use anyhow::Result; use tokio::sync::mpsc::Receiver; use tokio::sync::mpsc::Sender; use tokio::task::JoinSet; -// use tokio_stream::wrappers::ReceiverStream; +use tokio_stream::wrappers::ReceiverStream; use tokio_stream::StreamExt; use tonic::transport::Channel; @@ -62,11 +62,11 @@ pub async fn connect_and_run(conn_data: ConnectionData) -> Result<()> { let mut streaming_tasks = JoinSet::new(); streaming_tasks.spawn(receive_messages(client.clone(), conn_data.brain_msg_tx)); - // streaming_tasks.spawn(send_messages( - // client.clone(), - // conn_data.daemon_msg_rx, - // conn_data.daemon_msg_tx, - // )); + streaming_tasks.spawn(send_messages( + client.clone(), + conn_data.daemon_msg_rx, + conn_data.daemon_msg_tx, + )); let task_output = streaming_tasks.join_next().await; println!("exiting: {task_output:?}"); @@ -97,22 +97,19 @@ pub async fn receive_messages( Ok(()) } -/* pub async fn send_messages( - mut client: BrainSgxDaemonClient, - rx: Receiver, - tx: Sender, + mut client: BrainAppDaemonClient, + rx: Receiver, + tx: Sender, ) -> Result<()> { let pubkey = NODE_PUBKEY.to_string(); let rx_stream = ReceiverStream::new(rx); - tx.send(DaemonMessage { - msg: Some(Msg::Pubkey(Pubkey { pubkey })), + tx.send(DaemonMessageApp { + msg: Some(daemon_message_app::Msg::Pubkey(pubkey)), }) .await?; client.daemon_messages(rx_stream).await?; log::debug!("daemon_messages is about to exit"); Ok(()) } - - */ diff --git a/src/main.rs b/src/main.rs index af0ff85..fdcc981 100644 --- a/src/main.rs +++ b/src/main.rs @@ -70,24 +70,14 @@ impl ContainerHandler { Some(brain_message_app::Msg::NewAppReq(msg)) => { self.handle_new_container_req(msg.into()).await; } - /* - Some(brain_message::Msg::DeleteContainer(msg)) => { - let container_id = msg.uuid.unwrap_or_default(); - self.handle_del_container_req(container_id).await; + Some(brain_message_app::Msg::DeleteAppReq(msg)) => { + let app_id = msg.uuid; + self.handle_del_container_req(app_id).await; } - - Some(brain_message::Msg::ListContainer(msg)) => { - dbg!(&msg); - } - */ None => { log::error!("Brain disconnected"); break; } - - _ => { - todo!("wip") - } } } } @@ -104,7 +94,7 @@ impl ContainerHandler { Ok(unarchive_dir) => unarchive_dir, Err(e) => { let res = DaemonMessageApp { - msg: Some(daemon_message_app::Msg::NewAppResp(NewAppRes { + msg: Some(daemon_message_app::Msg::NewAppRes(NewAppRes { uuid: new_container_req.uuid, status: "failed".to_string(), error: e.to_string(), @@ -126,7 +116,7 @@ impl ContainerHandler { Ok(mapped_ports) => mapped_ports.into_iter().map(MappedPort::from).collect(), Err(e) => { let res = DaemonMessageApp { - msg: Some(daemon_message_app::Msg::NewAppResp(NewAppRes { + msg: Some(daemon_message_app::Msg::NewAppRes(NewAppRes { uuid: container_uuid, status: "failed".to_string(), error: e.to_string(), @@ -141,7 +131,7 @@ impl ContainerHandler { }; let res = DaemonMessageApp { - msg: Some(daemon_message_app::Msg::NewAppResp(NewAppRes { + msg: Some(daemon_message_app::Msg::NewAppRes(NewAppRes { uuid: container_uuid, status: "Success".to_string(), error: "".to_string(),