Conversation
Summary by CodeRabbit
Summary by CodeRabbit
WalkthroughThe polling logic for high-priority, low-priority, and response streams in Changes
Sequence Diagram(s)sequenceDiagram
actor ConnectionActor
participant HighPriorityRx as HighPriorityReceiver
participant LowPriorityRx as LowPriorityReceiver
participant ResponseStream
loop poll_sources
alt High-priority available
ConnectionActor->>HighPriorityRx: poll_receiver()
HighPriorityRx-->>ConnectionActor: Option<Frame>
ConnectionActor->>ConnectionActor: process_frame_common()
else Low-priority available
ConnectionActor->>LowPriorityRx: poll_receiver()
LowPriorityRx-->>ConnectionActor: Option<Frame>
ConnectionActor->>ConnectionActor: process_frame_common()
else Response available
ConnectionActor->>ResponseStream: poll_response()
ResponseStream-->>ConnectionActor: Option<Result<Frame, Error>>
ConnectionActor->>ConnectionActor: process response frame
end
end
Possibly related issues
Possibly related PRs
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (2)`**/*.rs`: Comment why, not what. Explain assumptions, edge cases, trade-offs, o...
📄 Source: CodeRabbit Inference Engine (AGENTS.md) List of files the instruction was applied to:
`**/*.rs`: * Seek to keep the cyclomatic complexity of functions no more than 12...
⚙️ Source: CodeRabbit Configuration File List of files the instruction was applied to:
⏰ Context from checks skipped due to timeout of 90000ms (2)
🔇 Additional comments (8)
✨ Finishing Touches
🧪 Generate Unit Tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Reviewer's GuideRefactors the connection’s polling loop by extracting inline async blocks for high-priority, low-priority, and response streams into dedicated poll_* functions, then updating the select arms to use these futures and removing the old next_response helper. File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Gates Failed
Enforce advisory code health rules
(1 file with Code Duplication)
Gates Passed
5 Quality Gates Passed
See analysis details in CodeScene
Reason for failure
| Enforce advisory code health rules | Violations | Code Health Impact | |
|---|---|---|---|
| connection.rs | 1 advisory rule | 10.00 → 9.39 | Suppress |
Quality Gate Profile: Pay Down Tech Debt
Want more control? Customize Code Health rules or catch issues early with our IDE extension and CLI tool.
There was a problem hiding this comment.
Hey @leynos - I've reviewed your changes and found some issues that need to be addressed.
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `src/connection.rs:175` </location>
<code_context>
- .expect("high_rx should be Some when high_available is true")
- ).await
- }, if high_available => {
+ res = Self::poll_high(self.high_rx.as_mut()), if high_available => {
self.process_high(res, state, out);
}
</code_context>
<issue_to_address>
Consider handling the case where high_rx is None more explicitly.
Ensure that process_high can handle None values from poll_high, as this differs from the previous expect() behavior.
</issue_to_address>
### Comment 2
<location> `src/connection.rs:179` </location>
<code_context>
- .expect("low_rx should be Some when low_available is true")
- ).await
- }, if low_available => {
+ res = Self::poll_low(self.low_rx.as_mut()), if low_available => {
self.process_low(res, state, out);
}
</code_context>
<issue_to_address>
The change from expect() to Option may mask logic errors.
Previously, a panic made inconsistent state obvious; now, poll_low returns None silently. If this state is a logic error, consider adding a debug_assert or explicit error handling to aid debugging.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| .expect("high_rx should be Some when high_available is true") | ||
| ).await | ||
| }, if high_available => { | ||
| res = Self::poll_high(self.high_rx.as_mut()), if high_available => { |
There was a problem hiding this comment.
issue (bug_risk): Consider handling the case where high_rx is None more explicitly.
Ensure that process_high can handle None values from poll_high, as this differs from the previous expect() behavior.
| .expect("low_rx should be Some when low_available is true") | ||
| ).await | ||
| }, if low_available => { | ||
| res = Self::poll_low(self.low_rx.as_mut()), if low_available => { |
There was a problem hiding this comment.
issue (bug_risk): The change from expect() to Option may mask logic errors.
Previously, a panic made inconsistent state obvious; now, poll_low returns None silently. If this state is a logic error, consider adding a debug_assert or explicit error handling to aid debugging.
There was a problem hiding this comment.
Actionable comments posted: 3
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
src/connection.rs(3 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
`**/*.rs`: Comment why, not what. Explain assumptions, edge cases, trade-offs, o...
**/*.rs: Comment why, not what. Explain assumptions, edge cases, trade-offs, or complexity. Don't echo the obvious.
Comments must use en-GB-oxendict spelling and grammar.
Function documentation must include clear examples.
Every module must begin with a module level (//!) comment explaining the module's purpose and utility.
Document public APIs using Rustdoc comments (///) so documentation can be generated with cargo doc.
Place function attributes after doc comments.
Do not usereturnin single-line functions.
Use predicate functions for conditional criteria with more than two branches.
Lints must not be silenced except as a last resort.
Lint rule suppressions must be tightly scoped and include a clear reason.
Preferexpectoverallow.
Prefer.expect()over.unwrap().
Clippy warnings MUST be disallowed.
Fix any warnings emitted during tests in the code itself rather than silencing them.
Where a function is too long, extract meaningfully named helper functions adhering to separation of concerns and CQRS.
Where a function has too many parameters, group related parameters in meaningfully named structs.
Where a function is returning a large error consider usingArcto reduce the amount of data returned.
Write unit and behavioural tests for new functionality. Run both before and after making any change.
Prefer immutable data and avoid unnecessarymutbindings.
Handle errors with theResulttype instead of panicking where feasible.
Avoidunsafecode unless absolutely necessary and document any usage clearly.
📄 Source: CodeRabbit Inference Engine (AGENTS.md)
List of files the instruction was applied to:
src/connection.rs
`**/*.rs`: * Seek to keep the cyclomatic complexity of functions no more than 12...
**/*.rs: * Seek to keep the cyclomatic complexity of functions no more than 12.
Adhere to single responsibility and CQRS
Place function attributes after doc comments.
Do not use
returnin single-line functions.Move conditionals with >2 branches into a predicate function.
Avoid
unsafeunless absolutely necessary.Every module must begin with a
//!doc comment that explains the module's purpose and utility.Comments must use en-GB-oxendict spelling and grammar.
Lints must not be silenced except as a last resort.
#[allow]is forbidden.- Only narrowly scoped
#[expect(lint, reason = "...")]is allowed.- No lint groups, no blanket or file-wide suppression.
- Include
FIXME:with link if a fix is expected.Use
rstestfixtures for shared setup and to avoid repetition between tests.Replace duplicated tests with
#[rstest(...)]parameterised cases.Prefer
mockallfor mocks/stubs.Prefer
.expect()over.unwrap()Ensure that any API or behavioural changes are reflected in the documentation in
docs/Ensure that any completed roadmap steps are recorded in the appropriate roadmap in
docs/
⚙️ Source: CodeRabbit Configuration File
List of files the instruction was applied to:
src/connection.rs
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: build-test
🔇 Additional comments (3)
src/connection.rs (3)
175-175: LGTM - Clean refactoring improves modularity.The replacement of inline async blocks with dedicated helper functions makes the select branches more readable and maintainable.
179-179: LGTM - Consistent with high-priority polling pattern.The low-priority polling follows the same clean pattern as the high-priority branch.
188-188: LGTM - Response polling refactored consistently.The response polling now follows the same pattern as the queue polling, improving consistency across the codebase.
Summary
Testing
cargo clippy --all-targets --all-features -- -D warningsRUSTFLAGS="-D warnings" cargo test --quiethttps://chatgpt.com/codex/tasks/task_e_68630f8d99308322bdbcb5b2d65a69a7
Summary by Sourcery
Extract the inline polling logic in the connection actor into dedicated helper methods for high-priority, low-priority, and response streams to simplify the select branches
Enhancements: