From 0fa8fba9d4632c465290d328bc43c53747a6b1d7 Mon Sep 17 00:00:00 2001 From: tsunyoku Date: Thu, 2 May 2024 19:56:25 +0100 Subject: [PATCH] attempt reducing cpu load by handling queue items one by one --- src/processor/mod.rs | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/processor/mod.rs b/src/processor/mod.rs index 0951d5b..e8e5771 100644 --- a/src/processor/mod.rs +++ b/src/processor/mod.rs @@ -454,19 +454,16 @@ async fn rmq_listen(context: Arc) -> anyhow::Result<()> { deserialized_data.rework_id ); - let context_clone = context.clone(); - tokio::spawn(async move { - let result = handle_queue_request( - deserialized_data, - context_clone, - delivery.delivery_tag.clone(), - ) - .await; - - if result.is_err() { - log::error!(error = result.unwrap_err().to_string(); "Error processing queue request"); - } - }); + let result = handle_queue_request( + deserialized_data, + context.clone(), + delivery.delivery_tag.clone(), + ) + .await; + + if result.is_err() { + log::error!(error = result.unwrap_err().to_string(); "Error processing queue request"); + } } tokio::time::sleep(Duration::from_millis(100)).await;