Description
Improve call-site clarity and prevent unit mistakes by accepting Duration directly instead of u64 seconds in the wait_or_shutdown function.
Problem
The current API takes secs: u64 which requires implicit unit conversion and is prone to unit mistakes. Using Duration is more explicit and type-safe.
Solution
Change the function signature and update call sites:
// Function signature
pub async fn wait_or_shutdown(duration: Duration, shutdown: &mut watch::Receiver<()>) {
tokio::select\! {
biased;
_ = shutdown.changed() => {},
_ = tokio::time::sleep(duration) => {},
}
}
// Call site update
WorkerHooks::wait_or_shutdown(Duration::from_secs(config.cooldown_period_seconds), shutdown).await;
Location
- File:
crates/comenqd/src/worker.rs
- Lines: 122-127
- Additional call sites need updating
References
Description
Improve call-site clarity and prevent unit mistakes by accepting Duration directly instead of u64 seconds in the
wait_or_shutdownfunction.Problem
The current API takes
secs: u64which requires implicit unit conversion and is prone to unit mistakes. Using Duration is more explicit and type-safe.Solution
Change the function signature and update call sites:
Location
crates/comenqd/src/worker.rsReferences