Add Apalis job timeout (15m)

This commit is contained in:
Luke Street
2026-05-23 21:01:27 -06:00
parent 874ceeb2fb
commit ac7cd266fe
2 changed files with 20 additions and 3 deletions
+11 -1
View File
@@ -61,10 +61,20 @@ pub struct WorkerConfig {
pub refresh_project_concurrency: usize,
/// Number of retry attempts for failed jobs.
pub retry_attempts: usize,
/// Maximum wall-clock seconds allowed for a single job attempt.
#[serde(default = "default_job_timeout_secs")]
pub job_timeout_secs: u64,
}
impl Default for WorkerConfig {
fn default() -> Self {
Self { workflow_run_concurrency: 3, refresh_project_concurrency: 3, retry_attempts: 5 }
Self {
workflow_run_concurrency: 3,
refresh_project_concurrency: 3,
retry_attempts: 5,
job_timeout_secs: default_job_timeout_secs(),
}
}
}
fn default_job_timeout_secs() -> u64 { 15 * 60 }
+9 -2
View File
@@ -86,8 +86,13 @@ pub fn create_monitor(
context: JobContext,
config: &WorkerConfig,
) -> Monitor {
let &WorkerConfig { workflow_run_concurrency, refresh_project_concurrency, retry_attempts } =
config;
let &WorkerConfig {
workflow_run_concurrency,
refresh_project_concurrency,
retry_attempts,
job_timeout_secs,
} = config;
let job_timeout = Duration::from_secs(job_timeout_secs);
let backoff = ExponentialBackoffMaker::new(
Duration::from_secs(1),
@@ -112,6 +117,7 @@ pub fn create_monitor(
.register(move |_| {
WorkerBuilder::new("workflow-run-worker")
.backend(storage1.workflow_run.clone())
.timeout(job_timeout)
.retry(retry1.clone())
.enable_tracing()
.catch_panic()
@@ -128,6 +134,7 @@ pub fn create_monitor(
.register(move |_| {
WorkerBuilder::new("refresh-project-worker")
.backend(storage2.refresh_project.clone())
.timeout(job_timeout)
.retry(retry2.clone())
.enable_tracing()
.catch_panic()