improve support for native http handling

This commit is contained in:
Ruben Fiszel
2023-06-25 20:00:27 +02:00
parent 4763242780
commit ee8f0e8def
8 changed files with 78 additions and 17 deletions
@@ -0,0 +1 @@
-- Add down migration script here
@@ -0,0 +1,4 @@
-- Add up migration script here
ALTER TYPE JOB_KIND ADD VALUE IF NOT EXISTS 'http';
ALTER TYPE JOB_KIND ADD VALUE IF NOT EXISTS 'graphql';
ALTER TYPE JOB_KIND ADD VALUE IF NOT EXISTS 'postgresql';
+6 -2
View File
@@ -5821,6 +5821,9 @@ components:
"flowpreview",
"script_hub",
"identity",
"http",
"graphql",
"postgresql",
]
schedule_path:
type: string
@@ -6268,11 +6271,12 @@ components:
enum: [python3, deno, go, bash]
tag:
type: string
kind:
type: string
enum: [code, identity, graphql, postgresql, http]
required:
- content
- args
- language
CreateResource:
type: object
+24 -8
View File
@@ -1234,12 +1234,22 @@ struct CancelJob {
reason: Option<String>,
}
#[derive(Deserialize)]
#[serde(rename_all = "lowercase")]
enum PreviewKind {
Code,
Identity,
Http,
Postgresql,
Graphql,
}
#[derive(Deserialize)]
struct Preview {
content: String,
content: Option<String>,
kind: Option<PreviewKind>,
path: Option<String>,
args: Option<serde_json::Map<String, serde_json::Value>>,
language: ScriptLang,
language: Option<ScriptLang>,
tag: Option<String>,
}
@@ -1963,12 +1973,18 @@ async fn run_preview_job(
let (uuid, tx) = push(
tx,
&w_id,
JobPayload::Code(RawCode {
content: preview.content,
path: preview.path,
language: preview.language,
lock: None,
}),
match preview.kind {
Some(PreviewKind::Identity) => JobPayload::Identity,
Some(PreviewKind::Http) => JobPayload::Http,
Some(PreviewKind::Graphql) => JobPayload::Graphql,
Some(PreviewKind::Postgresql) => JobPayload::Postgresql,
_ => JobPayload::Code(RawCode {
content: preview.content.unwrap_or_default(),
path: preview.path,
language: preview.language.unwrap_or(ScriptLang::Deno),
lock: None,
}),
},
args,
&authed.username,
&authed.email,
+1 -1
View File
@@ -946,7 +946,7 @@ pub async fn push<'c, R: rsmq_async::RsmqConnection + Send + 'c>(
}
JobPayload::Identity => (None, None, None, JobKind::Identity, None, None),
JobPayload::Graphql => (None, None, None, JobKind::Graphql, None, None),
JobPayload::Http => (None, None, None, JobKind::Identity, None, None),
JobPayload::Http => (None, None, None, JobKind::Http, None, None),
JobPayload::Postgresql => (None, None, None, JobKind::Postgresql, None, None),
};
+7
View File
@@ -95,6 +95,10 @@ await new Command()
"--flow-pattern <pattern:string>",
"Use a different flow pattern among: 2steps, onebranch (Default 2steps)"
)
.option(
"--script-pattern <pattern:string>",
"Use a different script pattern among: denotrivial, identity, httpversion (Default denotrivial)"
)
.option("--custom <custom_path:string>", "Use custom actions during bench")
.option(
"--zombie-timeout",
@@ -146,6 +150,7 @@ await new Command()
maximumThroughput,
useFlows,
flowPattern,
scriptPattern,
zombieTimeout,
continous,
max,
@@ -203,6 +208,7 @@ await new Command()
maximumThroughput,
useFlows,
flowPattern,
scriptPattern,
zombieTimeout,
},
null,
@@ -241,6 +247,7 @@ await new Command()
max_per_worker,
useFlows,
flowPattern,
scriptPattern,
continous,
custom: custom_content,
};
+34 -5
View File
@@ -11,6 +11,7 @@ const promise = new Promise<{
per_worker_throughput: number;
useFlows: boolean;
flowPattern: string;
scriptPattern: string;
continous: boolean;
max_per_worker: number;
custom: Action | undefined;
@@ -25,6 +26,7 @@ const promise = new Promise<{
per_worker_throughput: sharedConfig.per_worker_throughput,
useFlows: sharedConfig.useFlows,
flowPattern: sharedConfig.flowPattern,
scriptPattern: sharedConfig.scriptPattern,
continous: sharedConfig.continous,
max_per_worker: sharedConfig.max_per_worker,
custom: sharedConfig.custom,
@@ -162,13 +164,34 @@ while (cont) {
requestBody: payload,
});
} else {
uuid = await windmill.JobService.runScriptPreview({
workspace: config.workspace_id,
requestBody: {
let payload: api.Preview;
if (config.scriptPattern == "httpversion") {
payload = {
path: "httpversion",
kind: "http",
args: {
url: "http://localhost:8000/api/version",
},
};
} else if (config.scriptPattern == "identity") {
payload = {
path: "identity",
kind: "identity",
args: {
identity: "itsme",
},
};
} else {
payload = {
path: "denosimple",
language: api.Preview.language.DENO,
content: 'export function main(){ return Deno.env.get("WM_JOB_ID"); }',
args: {},
},
};
}
uuid = await windmill.JobService.runScriptPreview({
workspace: config.workspace_id,
requestBody: payload,
});
}
if (!config.continous) outstanding.push(uuid);
@@ -215,7 +238,11 @@ while (outstanding.length > 0 && Date.now() < end_time) {
} else {
r = r as api.CompletedJob;
try {
if (r.result != uuid) {
if (
config.scriptPattern != "httpversion" &&
config.scriptPattern != "identity" &&
r.result != uuid
) {
console.log(
"job did not return correct UUID: " +
r.result +
@@ -225,6 +252,8 @@ while (outstanding.length > 0 && Date.now() < end_time) {
JSON.stringify(r, null, 2)
);
incorrect_results++;
} else {
// console.log(r.result);
}
} catch (e) {
console.log("error during wait: ", e);
@@ -53,7 +53,7 @@
function computeJobKinds(jobKindsCat: string | undefined): string {
if (jobKindsCat == 'all') {
return `${CompletedJob.job_kind.SCRIPT},${CompletedJob.job_kind.FLOW},${CompletedJob.job_kind.DEPENDENCIES},${CompletedJob.job_kind.PREVIEW},${CompletedJob.job_kind.FLOWPREVIEW},${CompletedJob.job_kind.SCRIPT_HUB}`
return `${CompletedJob.job_kind.SCRIPT},${CompletedJob.job_kind.FLOW},${CompletedJob.job_kind.DEPENDENCIES},${CompletedJob.job_kind.PREVIEW},${CompletedJob.job_kind.FLOWPREVIEW},${CompletedJob.job_kind.SCRIPT_HUB},${CompletedJob.job_kind.HTTP},${CompletedJob.job_kind.GRAPHQL},${CompletedJob.job_kind.POSTGRESQL}`
} else if (jobKindsCat == 'dependencies') {
return CompletedJob.job_kind.DEPENDENCIES
} else if (jobKindsCat == 'previews') {