From fecdb94841955b66b9d2a9dde73d281eb043d766 Mon Sep 17 00:00:00 2001 From: Pakin Date: Wed, 22 Apr 2026 13:19:55 +0700 Subject: [PATCH] change: add check if sys message instead - change from confusing logging but it actually works Signed-off-by: Pakin --- src/main.rs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 8bd61ba..f871596 100644 --- a/src/main.rs +++ b/src/main.rs @@ -320,6 +320,13 @@ fn convert_ack_command(cmd_req: &serde_json::Value) -> Option Option { + match serde_json::from_value(msg.clone()) { + Ok(req) => Some(req), + Err(_) => None, + } +} + async fn read( // redis: redis::Client, mut state: Arc, @@ -335,7 +342,7 @@ async fn read( tokio::spawn(async move { // Send back to client from services while let Ok(s_msg) = system_rx.recv().await { - if convert_ack_command(&s_msg).is_none() + if convert_sys_msg_command(&s_msg).is_some() && let Some(err) = tx_to_client.send(s_msg).await.err() { println!("[SYS] failed to send back to client: {err}"); @@ -835,16 +842,19 @@ impl AppState { loop { if let Ok(rmsg) = system_rx.recv().await { - info!("receive msg: {rmsg:?}"); + let sys_msg = convert_sys_msg_command(&rmsg); + // add queue process let command_req: CommandRequestPayload = match serde_json::from_value(rmsg) { Ok(cmd) => cmd, Err(e) => { - error!("error deserialize: {e:?} ---> Skip"); + if sys_msg.is_none() { + // maybe error + error!("error deserialize: {e:?} ---> Skip"); + } continue; } // reject }; - info!("get cmd: {}", command_req.srv_name); if let Err(fail_payload) = current_queue.push(command_req.clone()) {