Unify the Incremental Execution Loop - #279
Conversation
Extract shared incremental loop logic into processor/incremental_loop.rs: - Sleep trait with SyncSleep and AsyncSleep adapters - Unified RequestProcessingResult enum - Deduplicated add_request_context helper - Generic process_requests_incremental function parameterized by Sleep - block_on helper for sync path - NativeSleep future moved from runner/incremental_async.rs
process_http_file_incremental and process_http_file_incremental_with_executor now delegate to the unified process_requests_incremental via SyncSleep and block_on. The duplicated loop logic and add_request_context helper are removed.
process_http_requests_incremental_async now delegates to the unified process_requests_incremental via AsyncSleep. AsyncRequestExecutor, AsyncRequestFuture, and AsyncRequestProcessingResult are re-exported from the unified module for backward compatibility. runner/mod.rs updated to export RequestProcessingResult from processor.
Replace AsyncRequestProcessingResult references with the unified RequestProcessingResult from httprunner_core::processor. Both types are now identical; this removes the duplicate enum usage.
|
Warning Review limit reached
More reviews will be available in 45 minutes and 30 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughA new ChangesCentralized incremental processing loop
Sequence Diagram(s)sequenceDiagram
rect rgba(135, 206, 235, 0.5)
Note over Caller,callback: process_requests_incremental (sync via block_on / async directly)
end
participant Caller
participant process_requests_incremental
participant conditions
participant executor
participant assertions
participant callback
Caller->>process_requests_incremental: requests, executor, Sleep impl, callback
loop for each HttpRequest
process_requests_incremental->>conditions: check_dependency(request, contexts)
process_requests_incremental->>conditions: evaluate_conditions(request, contexts)
alt dependency/condition not met
process_requests_incremental->>callback: RequestProcessingResult::Skipped(reason)
else execution error
process_requests_incremental->>callback: RequestProcessingResult::Failed(error)
else
process_requests_incremental->>executor: execute(request) → HttpResult
process_requests_incremental->>assertions: evaluate_assertions(result)
process_requests_incremental->>callback: RequestProcessingResult::Executed(result)
end
callback-->>process_requests_incremental: continue: bool
end
process_requests_incremental-->>Caller: Result<()>
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #279 +/- ##
==========================================
+ Coverage 91.12% 92.53% +1.40%
==========================================
Files 67 68 +1
Lines 8437 8663 +226
==========================================
+ Hits 7688 8016 +328
+ Misses 749 647 -102 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Use std::task::Waker::noop() (stabilized in Rust 1.80) instead of manual NoopWaker implementation in both block_on functions.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/core/src/processor/incremental_loop.rs`:
- Around line 345-359: The block_on function uses std::task::Waker::noop() which
requires Rust 1.85.0 or later. Either add rust-version = "1.85.0" to the
Cargo.toml file to document the minimum supported Rust version requirement, or
alternatively replace the Waker::noop() call with an implementation-compatible
alternative that works with earlier Rust versions if backward compatibility is
needed.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: f8d807e7-4d52-4623-b21a-4475a04f70c1
📒 Files selected for processing (7)
src/core/src/processor/incremental.rssrc/core/src/processor/incremental_loop.rssrc/core/src/processor/mod.rssrc/core/src/runner/incremental_async.rssrc/core/src/runner/mod.rssrc/gui/src/results_view.rssrc/gui/src/results_view_async.rs
| /// Block on a future using a no-op waker. | ||
| pub(crate) fn block_on<F: Future>(future: F) -> F::Output { | ||
| use std::task::{Context, Poll}; | ||
|
|
||
| let waker = std::task::Waker::noop(); | ||
| let mut context = Context::from_waker(waker); | ||
| let mut future = Box::pin(future); | ||
|
|
||
| loop { | ||
| match future.as_mut().poll(&mut context) { | ||
| Poll::Ready(output) => return output, | ||
| Poll::Pending => std::thread::yield_now(), | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
What Rust version stabilized std::task::Waker::noop?
💡 Result:
The std::task::Waker::noop method was stabilized in Rust version 1.85.0 [1][2]. The stabilization was implemented via a pull request merged on December 6, 2024, targeting the 1.85.0 milestone [2][3]. Before this, the feature was available as an experimental, nightly-only API [4][5].
Citations:
- 1: https://releases.rs/docs/1.85.0/
- 2: Stabilize noop_waker rust-lang/rust#133089
- 3: erickt/rust@8dc8377
- 4: https://doc.rust-lang.org/1.76.0/core/task/struct.Waker.html
- 5: https://dev-doc.rust-lang.org/beta/std/task/struct.Waker.html
🏁 Script executed:
# Find and check Cargo.toml for rust-version
fd -n "Cargo.toml$" | head -5 | xargs cat 2>/dev/null | grep -A 5 "rust-version\|edition"Repository: christianhelle/httprunner
Length of output: 300
🏁 Script executed:
# Search for all uses of Waker::noop in the codebase
rg "Waker::noop" --type rustRepository: christianhelle/httprunner
Length of output: 241
🏁 Script executed:
# Find and check root Cargo.toml for rust-version
find . -maxdepth 2 -name "Cargo.toml" -type f | head -3 | xargs grep -l "rust-version\|name\|version" 2>/dev/nullRepository: christianhelle/httprunner
Length of output: 82
🏁 Script executed:
# Check the root Cargo.toml specifically
cat Cargo.toml 2>/dev/null | head -20Repository: christianhelle/httprunner
Length of output: 829
🏁 Script executed:
# Check src/core/Cargo.toml for rust-version
cat src/core/Cargo.toml | grep -A 20 "^\[package\]"Repository: christianhelle/httprunner
Length of output: 590
🏁 Script executed:
# Check for rust-version files or CI configurations
fd -e "rust-toolchain" -e "rust-toolchain.toml" -e ".rust-version"Repository: christianhelle/httprunner
Length of output: 51
🏁 Script executed:
# Check CI configurations for minimum Rust version
fd -e "yml" -e "yaml" | xargs grep -l "rust-version\|toolchain" 2>/dev/null | head -5Repository: christianhelle/httprunner
Length of output: 51
Set MSRV to Rust 1.85.0 to use Waker::noop().
std::task::Waker::noop() requires Rust 1.85.0 or later. Add rust-version = "1.85.0" to Cargo.toml to document this requirement, or remove the use of Waker::noop() if you need to support earlier versions.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/core/src/processor/incremental_loop.rs` around lines 345 - 359, The
block_on function uses std::task::Waker::noop() which requires Rust 1.85.0 or
later. Either add rust-version = "1.85.0" to the Cargo.toml file to document the
minimum supported Rust version requirement, or alternatively replace the
Waker::noop() call with an implementation-compatible alternative that works with
earlier Rust versions if backward compatibility is needed.
17 new unit tests covering: - SyncSleep trait (zero/nonzero duration) - block_on helper (ready/future with Pending) - process_requests_incremental directly (without file parsing): empty, single, multiple, callback stops early, inter-request delay, dependency skip, condition skip, executor error, assertion failure, zero delay, pre-delay, post-delay, index tracking
This pull request refactors the incremental HTTP request processing logic to separate core execution from orchestration, enabling both synchronous and asynchronous operation. The main logic for incremental request processing is moved into a new
incremental_loopmodule, which introduces abstractions for sleep (sync/async), supports assertion evaluation, and provides a unified callback-driven control flow. This improves code organization, testability, and future extensibility for async runtimes.The most important changes are:
Refactoring and Modularization:
Extracted the core incremental request processing logic from
incremental.rsinto a newincremental_loop.rsmodule, centralizing dependency checks, condition evaluation, variable/function substitution, pre/post delays, and callback handling. ([[1]](https://github.com/christianhelle/httprunner/pull/279/files#diff-c5da75c76b1cb67d92ab6915eb609ac80023231e1c9fa22159da3c11dbdc9347L1-L34),[[2]](https://github.com/christianhelle/httprunner/pull/279/files#diff-ff9970f9790299721cf573c8db0f7f69012719652a12fb27a86800d8fb97359dR1-R365),[[3]](https://github.com/christianhelle/httprunner/pull/279/files#diff-338d60590d00295e243778226a2ca4643c21a3f5ad9cc5696de902b9c844753eR4))Introduced the
RequestProcessingResultenum and related types inincremental_loop.rsand re-exported them for use in the rest of the codebase, replacing the previous local definition. ([[1]](https://github.com/christianhelle/httprunner/pull/279/files#diff-c5da75c76b1cb67d92ab6915eb609ac80023231e1c9fa22159da3c11dbdc9347L1-L34),[[2]](https://github.com/christianhelle/httprunner/pull/279/files#diff-ff9970f9790299721cf573c8db0f7f69012719652a12fb27a86800d8fb97359dR1-R365))Sync/Async Execution and Sleep Abstraction:
Added the
Sleeptrait and its implementations (SyncSleep,AsyncSleep) to abstract over synchronous and asynchronous sleep mechanisms, allowing the processing loop to be used in both blocking and async contexts. ([src/core/src/processor/incremental_loop.rsR1-R365](https://github.com/christianhelle/httprunner/pull/279/files#diff-ff9970f9790299721cf573c8db0f7f69012719652a12fb27a86800d8fb97359dR1-R365))Provided a
block_onfunction for running async code synchronously with a custom no-op waker, enabling the sync orchestration layer to invoke the async processing logic. ([src/core/src/processor/incremental_loop.rsR1-R365](https://github.com/christianhelle/httprunner/pull/279/files#diff-ff9970f9790299721cf573c8db0f7f69012719652a12fb27a86800d8fb97359dR1-R365))Incremental Processing Improvements:
Updated
process_http_file_incremental_with_executorinincremental.rsto delegate to the new async processing loop, simplifying the orchestration and ensuring consistent behavior across sync and async modes. ([src/core/src/processor/incremental.rsL56-R56](https://github.com/christianhelle/httprunner/pull/279/files#diff-c5da75c76b1cb67d92ab6915eb609ac80023231e1c9fa22159da3c11dbdc9347L56-R56))Enhanced request execution to support assertion evaluation after request completion, updating the result accordingly. (
[src/core/src/processor/incremental_loop.rsR1-R365](https://github.com/christianhelle/httprunner/pull/279/files#diff-ff9970f9790299721cf573c8db0f7f69012719652a12fb27a86800d8fb97359dR1-R365))These changes lay the groundwork for future async support and improve maintainability by separating orchestration from core logic.
Summary by CodeRabbit