completed migrating to new proto structure
This commit is contained in:
parent
afaa478f46
commit
d5667e4cd1
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -290,7 +290,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "detee-shared"
|
name = "detee-shared"
|
||||||
version = "0.1.0"
|
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 = [
|
dependencies = [
|
||||||
"base64",
|
"base64",
|
||||||
"prost",
|
"prost",
|
||||||
|
@ -16,7 +16,7 @@ anyhow = "1.0.95"
|
|||||||
rand = "0.8.5"
|
rand = "0.8.5"
|
||||||
tokio-stream = "0.1.17"
|
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" }
|
# detee-shared = { path = "../detee-shared" }
|
||||||
log = "0.4.25"
|
log = "0.4.25"
|
||||||
serde = "1.0.217"
|
serde = "1.0.217"
|
||||||
|
29
src/grpc.rs
29
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::brain_app_daemon_client::BrainAppDaemonClient;
|
||||||
|
use detee_shared::pb::brain::daemon_message_app;
|
||||||
use detee_shared::pb::brain::{
|
use detee_shared::pb::brain::{
|
||||||
AppContract, BrainMessageApp, DaemonMessageApp, Pubkey, RegisterAppNodeReq,
|
AppContract, BrainMessageApp, DaemonMessageApp, Pubkey, RegisterAppNodeReq,
|
||||||
};
|
};
|
||||||
|
|
||||||
use anyhow::Result;
|
|
||||||
use tokio::sync::mpsc::Receiver;
|
use tokio::sync::mpsc::Receiver;
|
||||||
use tokio::sync::mpsc::Sender;
|
use tokio::sync::mpsc::Sender;
|
||||||
use tokio::task::JoinSet;
|
use tokio::task::JoinSet;
|
||||||
// use tokio_stream::wrappers::ReceiverStream;
|
use tokio_stream::wrappers::ReceiverStream;
|
||||||
use tokio_stream::StreamExt;
|
use tokio_stream::StreamExt;
|
||||||
use tonic::transport::Channel;
|
use tonic::transport::Channel;
|
||||||
|
|
||||||
@ -62,11 +62,11 @@ pub async fn connect_and_run(conn_data: ConnectionData) -> Result<()> {
|
|||||||
let mut streaming_tasks = JoinSet::new();
|
let mut streaming_tasks = JoinSet::new();
|
||||||
|
|
||||||
streaming_tasks.spawn(receive_messages(client.clone(), conn_data.brain_msg_tx));
|
streaming_tasks.spawn(receive_messages(client.clone(), conn_data.brain_msg_tx));
|
||||||
// streaming_tasks.spawn(send_messages(
|
streaming_tasks.spawn(send_messages(
|
||||||
// client.clone(),
|
client.clone(),
|
||||||
// conn_data.daemon_msg_rx,
|
conn_data.daemon_msg_rx,
|
||||||
// conn_data.daemon_msg_tx,
|
conn_data.daemon_msg_tx,
|
||||||
// ));
|
));
|
||||||
|
|
||||||
let task_output = streaming_tasks.join_next().await;
|
let task_output = streaming_tasks.join_next().await;
|
||||||
println!("exiting: {task_output:?}");
|
println!("exiting: {task_output:?}");
|
||||||
@ -97,22 +97,19 @@ pub async fn receive_messages(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
pub async fn send_messages(
|
pub async fn send_messages(
|
||||||
mut client: BrainSgxDaemonClient<Channel>,
|
mut client: BrainAppDaemonClient<Channel>,
|
||||||
rx: Receiver<DaemonMessage>,
|
rx: Receiver<DaemonMessageApp>,
|
||||||
tx: Sender<DaemonMessage>,
|
tx: Sender<DaemonMessageApp>,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let pubkey = NODE_PUBKEY.to_string();
|
let pubkey = NODE_PUBKEY.to_string();
|
||||||
|
|
||||||
let rx_stream = ReceiverStream::new(rx);
|
let rx_stream = ReceiverStream::new(rx);
|
||||||
tx.send(DaemonMessage {
|
tx.send(DaemonMessageApp {
|
||||||
msg: Some(Msg::Pubkey(Pubkey { pubkey })),
|
msg: Some(daemon_message_app::Msg::Pubkey(pubkey)),
|
||||||
})
|
})
|
||||||
.await?;
|
.await?;
|
||||||
client.daemon_messages(rx_stream).await?;
|
client.daemon_messages(rx_stream).await?;
|
||||||
log::debug!("daemon_messages is about to exit");
|
log::debug!("daemon_messages is about to exit");
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
*/
|
|
||||||
|
22
src/main.rs
22
src/main.rs
@ -70,24 +70,14 @@ impl ContainerHandler {
|
|||||||
Some(brain_message_app::Msg::NewAppReq(msg)) => {
|
Some(brain_message_app::Msg::NewAppReq(msg)) => {
|
||||||
self.handle_new_container_req(msg.into()).await;
|
self.handle_new_container_req(msg.into()).await;
|
||||||
}
|
}
|
||||||
/*
|
Some(brain_message_app::Msg::DeleteAppReq(msg)) => {
|
||||||
Some(brain_message::Msg::DeleteContainer(msg)) => {
|
let app_id = msg.uuid;
|
||||||
let container_id = msg.uuid.unwrap_or_default();
|
self.handle_del_container_req(app_id).await;
|
||||||
self.handle_del_container_req(container_id).await;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Some(brain_message::Msg::ListContainer(msg)) => {
|
|
||||||
dbg!(&msg);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
None => {
|
None => {
|
||||||
log::error!("Brain disconnected");
|
log::error!("Brain disconnected");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
_ => {
|
|
||||||
todo!("wip")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -104,7 +94,7 @@ impl ContainerHandler {
|
|||||||
Ok(unarchive_dir) => unarchive_dir,
|
Ok(unarchive_dir) => unarchive_dir,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
let res = DaemonMessageApp {
|
let res = DaemonMessageApp {
|
||||||
msg: Some(daemon_message_app::Msg::NewAppResp(NewAppRes {
|
msg: Some(daemon_message_app::Msg::NewAppRes(NewAppRes {
|
||||||
uuid: new_container_req.uuid,
|
uuid: new_container_req.uuid,
|
||||||
status: "failed".to_string(),
|
status: "failed".to_string(),
|
||||||
error: e.to_string(),
|
error: e.to_string(),
|
||||||
@ -126,7 +116,7 @@ impl ContainerHandler {
|
|||||||
Ok(mapped_ports) => mapped_ports.into_iter().map(MappedPort::from).collect(),
|
Ok(mapped_ports) => mapped_ports.into_iter().map(MappedPort::from).collect(),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
let res = DaemonMessageApp {
|
let res = DaemonMessageApp {
|
||||||
msg: Some(daemon_message_app::Msg::NewAppResp(NewAppRes {
|
msg: Some(daemon_message_app::Msg::NewAppRes(NewAppRes {
|
||||||
uuid: container_uuid,
|
uuid: container_uuid,
|
||||||
status: "failed".to_string(),
|
status: "failed".to_string(),
|
||||||
error: e.to_string(),
|
error: e.to_string(),
|
||||||
@ -141,7 +131,7 @@ impl ContainerHandler {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let res = DaemonMessageApp {
|
let res = DaemonMessageApp {
|
||||||
msg: Some(daemon_message_app::Msg::NewAppResp(NewAppRes {
|
msg: Some(daemon_message_app::Msg::NewAppRes(NewAppRes {
|
||||||
uuid: container_uuid,
|
uuid: container_uuid,
|
||||||
status: "Success".to_string(),
|
status: "Success".to_string(),
|
||||||
error: "".to_string(),
|
error: "".to_string(),
|
||||||
|
Loading…
Reference in New Issue
Block a user