Skip to content

Use Duration parameter instead of seconds in wait_or_shutdown #88

Description

@coderabbitai

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

Metadata

Metadata

Assignees

Labels

lowAin't annoying anyone but the QA department

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions