refactor(manager-core): single source for executor-timeout default

Stage 6 review Obs 1b: the 300s default lived as a literal in two
places (DEFAULT_ASYNC_EXEC_TIMEOUT in dispatcher.rs and
DEFAULT_SAFE_VISIBILITY_VS_EXEC_BUDGET_SECS in triggers_api.rs). A
future change to the dispatcher would silently leave the
visibility-timeout warn threshold out of sync.

Extract a single pub const DEFAULT_ASYNC_EXEC_TIMEOUT_SECS: u32 = 300
in dispatcher.rs, derive the existing Duration constant from it, and
re-export it under the triggers_api name so the validator's
self-contained semantics are preserved at the call site. Tests still
inject the value explicitly via TEST_SAFE_LIMIT — no behavior change.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
MechaCat02
2026-06-11 17:42:20 +02:00
parent e33a551ad5
commit 285a76f2e2
2 changed files with 12 additions and 5 deletions

View File

@@ -106,7 +106,13 @@ const DEFAULT_TICK_INTERVAL: Duration = Duration::from_millis(100);
/// platform-wide ceiling here. Matches `LocalExecutorClient`'s own /// platform-wide ceiling here. Matches `LocalExecutorClient`'s own
/// 5-minute cap. /// 5-minute cap.
/// F-Q-009: env-overridable via `PICLOUD_DISPATCHER_ASYNC_EXEC_TIMEOUT_SEC`. /// F-Q-009: env-overridable via `PICLOUD_DISPATCHER_ASYNC_EXEC_TIMEOUT_SEC`.
const DEFAULT_ASYNC_EXEC_TIMEOUT: Duration = Duration::from_secs(300); ///
/// `pub` so `triggers_api::validate_queue_visibility_timeout` can use
/// the same default for its warn-threshold — otherwise a change here
/// would silently leave the visibility-timeout warner out of sync.
pub const DEFAULT_ASYNC_EXEC_TIMEOUT_SECS: u32 = 300;
const DEFAULT_ASYNC_EXEC_TIMEOUT: Duration =
Duration::from_secs(DEFAULT_ASYNC_EXEC_TIMEOUT_SECS as u64);
/// Read `PICLOUD_DISPATCHER_TICK_INTERVAL_MS`; invalid values fall back /// Read `PICLOUD_DISPATCHER_TICK_INTERVAL_MS`; invalid values fall back
/// to the documented default with a tracing-warn. /// to the documented default with a tracing-warn.

View File

@@ -41,10 +41,11 @@ use crate::trigger_repo::{
const MIN_QUEUE_VISIBILITY_TIMEOUT_SECS: u32 = 30; const MIN_QUEUE_VISIBILITY_TIMEOUT_SECS: u32 = 30;
/// Default soft-warning ceiling when `PICLOUD_DISPATCHER_ASYNC_EXEC_TIMEOUT_SEC` /// Default soft-warning ceiling when `PICLOUD_DISPATCHER_ASYNC_EXEC_TIMEOUT_SEC`
/// is unset — matches `DEFAULT_ASYNC_EXEC_TIMEOUT` in dispatcher.rs. /// is unset. Re-exported from the dispatcher so the single source of
/// Kept as a constant rather than imported so the validator stays /// truth for the executor-budget default lives in one place — a future
/// self-contained for unit tests. /// change to the dispatcher default shifts the visibility-timeout warn
const DEFAULT_SAFE_VISIBILITY_VS_EXEC_BUDGET_SECS: u32 = 300; /// boundary in lockstep.
use crate::dispatcher::DEFAULT_ASYNC_EXEC_TIMEOUT_SECS as DEFAULT_SAFE_VISIBILITY_VS_EXEC_BUDGET_SECS;
/// Read the dispatcher's per-message executor budget at validation /// Read the dispatcher's per-message executor budget at validation
/// time so the warn-threshold tracks the live env-overridable value /// time so the warn-threshold tracks the live env-overridable value