remove http as jobs

This commit is contained in:
Ruben Fiszel
2023-08-02 18:46:16 +02:00
parent af29692ee1
commit 81a85d3b68
6 changed files with 62 additions and 66 deletions
+60 -7
View File
@@ -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:
-1
View File
@@ -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(),
-2
View File
@@ -23,7 +23,6 @@ pub enum JobKind {
FlowPreview,
Identity,
FlowDependencies,
Http,
Noop,
}
@@ -183,7 +182,6 @@ pub enum JobPayload {
path: Option<String>,
},
Identity,
Http,
Noop,
}
-2
View File
@@ -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",
};
+2 -52
View File
@@ -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<JobCompleted> {
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<Postgres>) -> Result<String, Error> {
@@ -1049,27 +1024,7 @@ async fn handle_queued_job<R: rsmq_async::RsmqConnection + Send + Sync + Clone>(
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<Postgres> = db.clone();
@@ -1257,13 +1212,8 @@ async fn handle_queued_job<R: rsmq_async::RsmqConnection + Send + Sync + Clone>(
}
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) {
-2
View File
@@ -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: