Prioritize shutdown in wait_or_shutdown select#123
Conversation
Add `biased;` directive to the tokio::select! macro and reorder the arms so the shutdown branch is checked first. This ensures that when both the sleep timer and shutdown signal are ready simultaneously, shutdown is always selected, providing more responsive graceful shutdown behaviour. Fixes #87 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Reviewer's guide (collapsed on small PRs)Reviewer's GuideMakes the worker wait_or_shutdown helper prefer reacting to shutdown signals over completing its sleep delay by using a biased tokio::select! with the shutdown branch first. Sequence diagram for biased wait_or_shutdown shutdown prioritizationsequenceDiagram
actor Worker
participant WaitOrShutdown
participant ShutdownSignal
participant Timer
Worker->>WaitOrShutdown: wait_or_shutdown(secs, shutdown)
WaitOrShutdown->>Timer: start sleep(secs)
WaitOrShutdown->>ShutdownSignal: listen for changed()
rect rgb(230,230,255)
note over WaitOrShutdown: tokio::select! with biased and shutdown branch first
alt shutdown signal becomes ready (possibly with timer also ready)
ShutdownSignal-->>WaitOrShutdown: changed() ready
Timer-->>WaitOrShutdown: sleep may also be ready
WaitOrShutdown-->>Worker: return due to shutdown
else only timer becomes ready
Timer-->>WaitOrShutdown: sleep finished
WaitOrShutdown-->>Worker: return due to timeout
end
end
State diagram for worker wait_or_shutdown behaviorstateDiagram-v2
[*] --> Waiting
state Waiting {
[*] --> Pending
Pending --> ShuttingDown: shutdown.changed ready
Pending --> TimedOut: sleep finished
}
ShuttingDown --> [*]
TimedOut --> [*]
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings. WalkthroughModify Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related issues
Poem
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (1)**/*.rs📄 CodeRabbit inference engine (AGENTS.md)
Files:
⚙️ CodeRabbit configuration file
Files:
🔍 Remote MCPLet me search for more specific information about the PR Review Context SummarySystem Architecture ContextThe comenq system is a GitHub comment management service with a client-daemon architecture. The daemon implements a three-task concurrent architecture using Change Location and ScopeThe PR modifies the daemon's task coordination logic. The Current Behavior and IssueThe issue (#87) describes that Proposed Solution AnalysisThe PR implements two key changes:
Related System ContextThe daemon uses Rate Limiting ContextThe daemon enforces rate limiting through a fixed cooldown period after each request attempt using Code Quality ConsiderationsThe project enforces strict code quality through Clippy linting rules including panic prevention with ⏰ Context from checks skipped due to timeout of 120000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
🔇 Additional comments (2)
Comment |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
Add
biased;directive to the tokio::select! macro and reorder the arms so the shutdown branch is checked first. This ensures that when both the sleep timer and shutdown signal are ready simultaneously, shutdown is always selected, providing more responsive graceful shutdown behaviour.Fixes #87
🤖 Generated with Claude Code
Summary by Sourcery
Enhancements: