From 21a7ee4c33c483d39cc6d7020623ee11fc9f1cbd Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Sat, 6 Apr 2024 16:05:32 +0200 Subject: [PATCH] feat: add overridable cache_ttl in api of job triggers --- backend/windmill-api/openapi.yaml | 10 ++++++++++ backend/windmill-api/src/jobs.rs | 12 +++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/backend/windmill-api/openapi.yaml b/backend/windmill-api/openapi.yaml index c9a5d87f05..c56dbe2bef 100644 --- a/backend/windmill-api/openapi.yaml +++ b/backend/windmill-api/openapi.yaml @@ -3890,6 +3890,7 @@ paths: type: integer - $ref: "#/components/parameters/ParentJob" - $ref: "#/components/parameters/WorkerTag" + - $ref: "#/components/parameters/CacheTtl" - $ref: "#/components/parameters/NewJobId" - name: invisible_to_owner description: make the run invisible to the the script owner (default false) @@ -3953,6 +3954,7 @@ paths: - $ref: "#/components/parameters/ScriptPath" - $ref: "#/components/parameters/ParentJob" - $ref: "#/components/parameters/WorkerTag" + - $ref: "#/components/parameters/CacheTtl" - $ref: "#/components/parameters/NewJobId" - $ref: "#/components/parameters/IncludeHeader" - $ref: "#/components/parameters/QueueLimit" @@ -3982,6 +3984,7 @@ paths: - $ref: "#/components/parameters/ScriptPath" - $ref: "#/components/parameters/ParentJob" - $ref: "#/components/parameters/WorkerTag" + - $ref: "#/components/parameters/CacheTtl" - $ref: "#/components/parameters/NewJobId" - $ref: "#/components/parameters/IncludeHeader" - $ref: "#/components/parameters/QueueLimit" @@ -5039,6 +5042,7 @@ paths: type: integer - $ref: "#/components/parameters/ParentJob" - $ref: "#/components/parameters/WorkerTag" + - $ref: "#/components/parameters/CacheTtl" - $ref: "#/components/parameters/NewJobId" - $ref: "#/components/parameters/IncludeHeader" - name: invisible_to_owner @@ -8010,6 +8014,12 @@ components: in: query schema: type: string + CacheTtl: + name: tag + description: Override the cache time to live (in seconds). Can not be used to disable caching, only override with a new cache ttl + in: query + schema: + type: string NewJobId: name: job_id description: diff --git a/backend/windmill-api/src/jobs.rs b/backend/windmill-api/src/jobs.rs index 4a05ccec47..be25a89bd6 100644 --- a/backend/windmill-api/src/jobs.rs +++ b/backend/windmill-api/src/jobs.rs @@ -792,6 +792,7 @@ pub struct RunJobQuery { job_id: Option, tag: Option, timeout: Option, + cache_ttl: Option, } impl RunJobQuery { @@ -2888,13 +2889,16 @@ pub async fn run_wait_result_script_by_hash( tag, concurrent_limit, concurrency_time_window_s, - cache_ttl, + mut cache_ttl, language, dedicated_worker, priority, delete_after_use, timeout, ) = get_path_tag_limits_cache_for_hash(&db, &w_id, hash).await?; + if let Some(run_query_cache_ttl) = run_query.cache_ttl { + cache_ttl = Some(run_query_cache_ttl); + } check_scopes(&authed, || format!("run:script/{path}"))?; let tag = run_query.tag.clone().or(tag); @@ -3409,7 +3413,7 @@ pub async fn run_job_by_hash( tag, concurrent_limit, concurrency_time_window_s, - cache_ttl, + mut cache_ttl, language, dedicated_worker, priority, @@ -3417,7 +3421,9 @@ pub async fn run_job_by_hash( timeout, ) = get_path_tag_limits_cache_for_hash(&db, &w_id, hash).await?; check_scopes(&authed, || format!("run:script/{path}"))?; - + if let Some(run_query_cache_ttl) = run_query.cache_ttl { + cache_ttl = Some(run_query_cache_ttl); + } let scheduled_for = run_query.get_scheduled_for(&db).await?; let tag = run_query.tag.clone().or(tag);