From 81a85d3b68b3e3b53fcaabac8debfe389b154142 Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Wed, 2 Aug 2023 18:46:16 +0200 Subject: [PATCH] remove http as jobs --- backend/windmill-api/openapi.yaml | 67 ++++++++++++++++++++++++--- backend/windmill-api/src/jobs.rs | 1 - backend/windmill-common/src/jobs.rs | 2 - backend/windmill-queue/src/jobs.rs | 2 - backend/windmill-worker/src/worker.rs | 54 +-------------------- openflow.openapi.yaml | 2 - 6 files changed, 62 insertions(+), 66 deletions(-) diff --git a/backend/windmill-api/openapi.yaml b/backend/windmill-api/openapi.yaml index 47931fe9be..fd2860f9c8 100644 --- a/backend/windmill-api/openapi.yaml +++ b/backend/windmill-api/openapi.yaml @@ -5672,7 +5672,18 @@ components: language: type: string enum: - [python3, deno, go, bash, postgresql, mysql, bigquery, graphql, nativets, bun] + [ + python3, + deno, + go, + bash, + postgresql, + mysql, + bigquery, + graphql, + nativets, + bun, + ] kind: type: string enum: [script, failure, trigger, command, approval] @@ -5737,7 +5748,18 @@ components: language: type: string enum: - [python3, deno, go, bash, postgresql, mysql, bigquery, graphql, nativets, bun] + [ + python3, + deno, + go, + bash, + postgresql, + mysql, + bigquery, + graphql, + nativets, + bun, + ] kind: type: string enum: [script, failure, trigger, command, approval] @@ -5890,7 +5912,6 @@ components: "flowpreview", "script_hub", "identity", - "http", ] schedule_path: type: string @@ -5908,7 +5929,18 @@ components: language: type: string enum: - [python3, deno, go, bash, postgresql, mysql, bigquery, graphql, nativets, bun] + [ + python3, + deno, + go, + bash, + postgresql, + mysql, + bigquery, + graphql, + nativets, + bun, + ] email: type: string visible_to_owner: @@ -5981,7 +6013,6 @@ components: "flowpreview", "script_hub", "identity", - "http", ] schedule_path: type: string @@ -5999,7 +6030,18 @@ components: language: type: string enum: - [python3, deno, go, bash, postgresql, mysql, bigquery, graphql, nativets, bun] + [ + python3, + deno, + go, + bash, + postgresql, + mysql, + bigquery, + graphql, + nativets, + bun, + ] is_skipped: type: boolean email: @@ -6428,7 +6470,18 @@ components: language: type: string enum: - [python3, deno, go, bash, postgresql, mysql, bigquery, graphql, nativets, bun] + [ + python3, + deno, + go, + bash, + postgresql, + mysql, + bigquery, + graphql, + nativets, + bun, + ] tag: type: string kind: diff --git a/backend/windmill-api/src/jobs.rs b/backend/windmill-api/src/jobs.rs index 210e491764..21bdd86e3c 100644 --- a/backend/windmill-api/src/jobs.rs +++ b/backend/windmill-api/src/jobs.rs @@ -2097,7 +2097,6 @@ async fn run_preview_job( &w_id, match preview.kind { Some(PreviewKind::Identity) => JobPayload::Identity, - Some(PreviewKind::Http) => JobPayload::Http, Some(PreviewKind::Noop) => JobPayload::Noop, _ => JobPayload::Code(RawCode { content: preview.content.unwrap_or_default(), diff --git a/backend/windmill-common/src/jobs.rs b/backend/windmill-common/src/jobs.rs index 78c09fe0ea..c45093f40b 100644 --- a/backend/windmill-common/src/jobs.rs +++ b/backend/windmill-common/src/jobs.rs @@ -23,7 +23,6 @@ pub enum JobKind { FlowPreview, Identity, FlowDependencies, - Http, Noop, } @@ -183,7 +182,6 @@ pub enum JobPayload { path: Option, }, Identity, - Http, Noop, } diff --git a/backend/windmill-queue/src/jobs.rs b/backend/windmill-queue/src/jobs.rs index 13479ded5f..ae9dd38d6c 100644 --- a/backend/windmill-queue/src/jobs.rs +++ b/backend/windmill-queue/src/jobs.rs @@ -1263,7 +1263,6 @@ pub async fn push<'c, R: rsmq_async::RsmqConnection + Send + 'c>( ) } JobPayload::Identity => (None, None, None, JobKind::Identity, None, None, None, None), - JobPayload::Http => (None, None, None, JobKind::Http, None, None, None, None), JobPayload::Noop => (None, None, None, JobKind::Noop, None, None, None, None), }; @@ -1406,7 +1405,6 @@ pub async fn push<'c, R: rsmq_async::RsmqConnection + Send + 'c>( JobKind::Script_Hub => "jobs.run.script_hub", JobKind::Dependencies => "jobs.run.dependencies", JobKind::Identity => "jobs.run.identity", - JobKind::Http => "jobs.run.http", JobKind::Noop => "jobs.run.noop", JobKind::FlowDependencies => "jobs.run.flow_dependencies", }; diff --git a/backend/windmill-worker/src/worker.rs b/backend/windmill-worker/src/worker.rs index 7c66d495b3..1f93667cf2 100644 --- a/backend/windmill-worker/src/worker.rs +++ b/backend/windmill-worker/src/worker.rs @@ -10,7 +10,6 @@ use anyhow::Result; use const_format::concatcp; use itertools::Itertools; use once_cell::sync::OnceCell; -use serde::Deserialize; use sqlx::{Pool, Postgres}; use windmill_api_client::Client; use windmill_parser::Typ; @@ -920,30 +919,6 @@ fn hash_args(v: &serde_json::Value) -> i64 { dh.finish() as i64 } -#[derive(Deserialize)] -struct HttpArgs { - url: String -} - - - -async fn do_http_req(job: QueuedJob) -> windmill_common::error::Result { - let http_args: HttpArgs = serde_json::from_value(job.args.clone().unwrap_or_else(|| json!({}))) - .map_err(|e| Error::ExecutionErr(e.to_string()))?; - let res = HTTP_CLIENT.get(http_args.url).send().await.map_err(|e| Error::ExecutionErr(format!("Invalid http request: {e}")))?; - let res = if res.headers().get("Content-Type").is_some_and(|x| x == "application/json") { - res.json().await.map_err(|e| Error::ExecutionErr(format!("Invalid http response: {e}")))? - } else { - serde_json::Value::String(res.text().await.map_err(|e| Error::ExecutionErr(format!("Invalid http response: {e}")))?) - }; - return Ok(JobCompleted { - job: job, - result: res, - logs: "".to_string(), - success: true - }); -} - pub async fn get_content(job: &QueuedJob, db: &Pool) -> Result { @@ -1049,27 +1024,7 @@ async fn handle_queued_job( set_logs(&logs, &job.id, db).await; if !job.is_flow_step { - if matches!(job.job_kind, JobKind::Http) { - wait_available_worker_for_native_job(parallel_count.clone(), &job).await; - tokio::task::spawn(async move { - let jc = do_http_req(job.clone()).await; - parallel_count.fetch_sub(1, Ordering::SeqCst); - - match jc { - Ok(jc) => job_completed_tx.send(jc).await.expect("send job completed"), - Err(e) => job_completed_tx.send(JobCompleted { - job: job, - result: json!({"error": { - "name": "ExecutionError", - "message": e.to_string() - }}), - logs: "".to_string(), - success: false - }).await.expect("send job completed"), - }; - }); - return Ok(()); - } else if job.language == Some(ScriptLang::Postgresql) { + if job.language == Some(ScriptLang::Postgresql) { wait_available_worker_for_native_job(parallel_count.clone(), &job).await; let client = client.get_authed().await; let db: Pool = db.clone(); @@ -1257,13 +1212,8 @@ async fn handle_queued_job( } args @ _ => Ok(args.unwrap_or_else(|| Value::Null)), }, - JobKind::Http => { - panic!("should not be here") - }, _ => { - if matches!(job.job_kind, JobKind::Http) { - unreachable!() - } else if job.language == Some(ScriptLang::Postgresql) { + if job.language == Some(ScriptLang::Postgresql) { let jc = do_postgresql(job.clone(), &client.get_authed().await, &db).await?; Ok(jc.result) } else if job.language == Some(ScriptLang::Mysql) { diff --git a/openflow.openapi.yaml b/openflow.openapi.yaml index c47fe4764e..bb06db600c 100644 --- a/openflow.openapi.yaml +++ b/openflow.openapi.yaml @@ -162,7 +162,6 @@ components: - $ref: "#/components/schemas/BranchOne" - $ref: "#/components/schemas/BranchAll" - $ref: "#/components/schemas/Identity" - - $ref: "#/components/schemas/Http" - $ref: "#/components/schemas/Graphql" discriminator: propertyName: type @@ -174,7 +173,6 @@ components: branchone: "#/components/schemas/BranchOne" branchall: "#/components/schemas/BranchAll" identity: "#/components/schemas/Identity" - http: "#/components/schemas/Http" graphql: "#/components/schemas/Graphql" RawScript: