Skip to content

refactor: extract shutdown timeout magic numbers to constants#11

Open
bianbiandashen wants to merge 1 commit into
runta-dev:mainfrom
bianbiandashen:refactor/extract-shutdown-constants
Open

refactor: extract shutdown timeout magic numbers to constants#11
bianbiandashen wants to merge 1 commit into
runta-dev:mainfrom
bianbiandashen:refactor/extract-shutdown-constants

Conversation

@bianbiandashen

Copy link
Copy Markdown
Contributor

Summary

  • Extract hardcoded magic numbers in stop_process() to named constants
  • GRACEFUL_SHUTDOWN_TIMEOUT_MS = 10_000 (10 seconds total wait)
  • SHUTDOWN_POLL_INTERVAL_MS = 100 (polling interval)

Why

  • Makes the shutdown behavior self-documenting
  • Easier to tune timeouts if needed
  • Improves code readability

Changes

  • src/process.rs

Test plan

  • Existing tests still pass
  • No behavioral change, only code clarity improvement

- Add GRACEFUL_SHUTDOWN_TIMEOUT_MS (10 seconds)
- Add SHUTDOWN_POLL_INTERVAL_MS (100ms)
- Makes the shutdown behavior more self-documenting and easier to tune
Comment thread src/process.rs
Comment on lines +9 to +14
/// Maximum time to wait for graceful shutdown before sending SIGKILL (in milliseconds).
const GRACEFUL_SHUTDOWN_TIMEOUT_MS: u64 = 10_000;

/// Interval between checks when waiting for process to exit (in milliseconds).
const SHUTDOWN_POLL_INTERVAL_MS: u64 = 100;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is best to use const variables of type std::time::Duration here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants