feat: add overridable cache_ttl in api of job triggers

This commit is contained in:
Ruben Fiszel
2024-04-06 16:05:32 +02:00
parent f9d8dde61c
commit 21a7ee4c33
2 changed files with 19 additions and 3 deletions
+10
View File
@@ -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:
+9 -3
View File
@@ -792,6 +792,7 @@ pub struct RunJobQuery {
job_id: Option<Uuid>,
tag: Option<String>,
timeout: Option<i32>,
cache_ttl: Option<i32>,
}
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);