From 161436644e5cd0afefa5c3b67946d84eb91cb12c Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Sat, 2 Mar 2024 13:51:28 +0100 Subject: [PATCH] nit vacuum iterator --- backend/windmill-worker/src/worker.rs | 76 ++++++++++++--------------- 1 file changed, 33 insertions(+), 43 deletions(-) diff --git a/backend/windmill-worker/src/worker.rs b/backend/windmill-worker/src/worker.rs index fa15d9c208..5579beaef8 100644 --- a/backend/windmill-worker/src/worker.rs +++ b/backend/windmill-worker/src/worker.rs @@ -15,9 +15,9 @@ use prometheus::{ IntCounter, }; #[cfg(feature = "prometheus")] -use windmill_common::METRICS_ENABLED; -#[cfg(feature = "prometheus")] use windmill_common::METRICS_DEBUG_ENABLED; +#[cfg(feature = "prometheus")] +use windmill_common::METRICS_ENABLED; use reqwest::Response; use serde::{de::DeserializeOwned, Deserialize, Serialize}; @@ -51,16 +51,14 @@ use windmill_common::{ DB, IS_READY, }; - use windmill_queue::{ - canceled_job_to_result, empty_result, get_queued_job, pull, push, CanceledBy, - PushArgs, PushIsolationLevel, WrappedError, HTTP_CLIENT, + canceled_job_to_result, empty_result, get_queued_job, pull, push, CanceledBy, PushArgs, + PushIsolationLevel, WrappedError, HTTP_CLIENT, }; #[cfg(feature = "prometheus")] use windmill_queue::register_metric; - use serde_json::{json, value::RawValue, Value}; #[cfg(any(target_os = "linux", target_os = "macos"))] @@ -227,7 +225,6 @@ const VACUUM_PERIOD: u32 = 10000; pub const MAX_BUFFERED_DEDICATED_JOBS: usize = 3; - #[cfg(feature = "prometheus")] lazy_static::lazy_static! { @@ -502,7 +499,7 @@ macro_rules! add_time { } #[cfg(feature = "prometheus")] -type Histo =Arc; +type Histo = Arc; #[cfg(feature = "prometheus")] type GGauge = Arc>; @@ -511,7 +508,6 @@ type Histo = (); #[cfg(not(feature = "prometheus"))] type GGauge = (); - async fn handle_receive_completed_job< R: rsmq_async::RsmqConnection + Send + Sync + Clone + 'static, >( @@ -570,11 +566,7 @@ async fn handle_receive_completed_job< } #[derive(Clone)] -pub struct JobCompletedSender( - Sender, - Option, - Option, -); +pub struct JobCompletedSender(Sender, Option, Option); pub struct SameWorkerPayload { pub job_id: Uuid, @@ -586,7 +578,6 @@ impl JobCompletedSender { &self, jc: JobCompleted, ) -> Result<(), tokio::sync::mpsc::error::SendError> { - #[cfg(feature = "prometheus")] if let Some(wj) = self.1.as_ref() { wj.inc() @@ -708,9 +699,8 @@ pub async fn run_worker { last_executed_job = None; @@ -1720,7 +1705,7 @@ pub async fn run_worker( ) .await?; inner_tx.commit().await?; - same_worker_tx.send(SameWorkerPayload{ job_id: uuid, recoverable: false}).await.map_err(to_anyhow)?; + same_worker_tx + .send(SameWorkerPayload { job_id: uuid, recoverable: false }) + .await + .map_err(to_anyhow)?; tracing::info!("Creating initial job {uuid} from initial script script: {content}"); } Ok(()) @@ -2405,20 +2393,22 @@ pub async fn handle_job_error