fix: type matching on live_vmnode_msgs

generic type matching to table name
update type paths with
some logging in tests
This commit is contained in:
Noor 2025-05-06 17:25:42 +05:30
parent cf232f83b3
commit 4dfaa3f465
Signed by: noormohammedb
GPG Key ID: D83EFB8B3B967146
2 changed files with 8 additions and 4 deletions

@ -90,9 +90,9 @@ pub async fn live_vmnode_msgs<
tx: Sender<vm::VmDaemonMsg>,
) -> Result<(), Error> {
let table_name = match std::any::type_name::<T>() {
"surreal_brain::db::NewVmReq" => NEW_VM_REQ.to_string(),
"surreal_brain::db::UpdateVmReq" => UPDATE_VM_REQ.to_string(),
"surreal_brain::db::DeletedVm" => DELETED_VM.to_string(),
t if t == std::any::type_name::<crate::db::vm::NewVmReq>() => NEW_VM_REQ.to_string(),
t if t == std::any::type_name::<crate::db::vm::UpdateVmReq>() => UPDATE_VM_REQ.to_string(),
t if t == std::any::type_name::<crate::db::vm::DeletedVm>() => DELETED_VM.to_string(),
wat => {
log::error!("listen_for_node: T has type {wat}");
String::from("wat")
@ -109,7 +109,7 @@ pub async fn live_vmnode_msgs<
}
}
Err(e) => {
log::warn!("listen_for_deletion DB stream failed for {node}: {e}");
log::error!("listen_for_{table_name} DB stream failed for {node}: {e}");
return Err(Error::from(e));
}
}

@ -37,6 +37,7 @@ pub async fn register_vm_node(
key: Key,
operator_wallet: String,
) -> Vec<vm_proto::VmContract> {
log::info!("Registering vm_node: {}", key.pubkey);
let node_pubkey = key.pubkey.clone();
let req = RegisterVmNodeReq {
@ -71,6 +72,7 @@ pub async fn daemon_listener(
key: Key,
tx: mpsc::Sender<vm_proto::BrainVmMessage>,
) {
log::info!("listening vm_daemon");
let mut grpc_stream =
client.brain_messages(key.sign_stream_auth(vec![]).unwrap()).await.unwrap().into_inner();
@ -86,6 +88,7 @@ pub async fn daemon_msg_sender(
tx: mpsc::Sender<vm_proto::VmDaemonMessage>,
rx: mpsc::Receiver<vm_proto::VmDaemonMessage>,
) {
log::info!("sender vm_daemon");
let rx_stream = ReceiverStream::new(rx);
tx.send(vm_proto::VmDaemonMessage {
msg: Some(vm_proto::vm_daemon_message::Msg::Auth(key.sign_stream_auth(vec![]).unwrap())),
@ -99,6 +102,7 @@ pub async fn daemon_engine(
tx: mpsc::Sender<vm_proto::VmDaemonMessage>,
mut rx: mpsc::Receiver<vm_proto::BrainVmMessage>,
) {
log::info!("daemon engine vm_daemon");
while let Some(brain_msg) = rx.recv().await {
match brain_msg.msg {
Some(vm_proto::brain_vm_message::Msg::NewVmReq(new_vm_req)) => {