feat(common): add deferred poll timeout support - #3948
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3948 +/- ##
============================================
- Coverage 83.93% 83.73% -0.20%
Complexity 1358 1358
============================================
Files 1213 1214 +1
Lines 168441 168258 -183
Branches 135999 135941 -58
============================================
- Hits 141373 140884 -489
- Misses 23389 23557 +168
- Partials 3679 3817 +138
🚀 New features to boost your workflow:
|
Signed-off-by: Arun Singh <arunsingh.in@gmail.com>
Signed-off-by: Arun Singh <arunsingh.in@gmail.com>
a4486d1 to
d86e92b
Compare
hubcio
left a comment
There was a problem hiding this comment.
i dont see a point in merging this PR because there is no working path: every non-zero timeout is rejected by the server and by the SDK default impl, so this merges a public API and a wire field for a feature that does not exist. either put the waiter in this PR or cut it down to the protocol hunk and drop the trait method and the rejection test. Closes #3470 has to go either way - merging this would close the issue with nothing implemented. IggyConsumer still sleeps on poll_interval, so the high level consumer needs another pass even after the server side lands.
| /// immediately available. A zero timeout preserves immediate polling. | ||
| /// Transports without deferred-poll support return `FeatureUnavailable`. | ||
| #[allow(clippy::too_many_arguments)] | ||
| async fn poll_messages_with_timeout( |
There was a problem hiding this comment.
any non-zero timeout fails on every transport, so this is a public method with no working path. it also freezes the shape (8 positional args, Duration) before a server exists to validate it - hold the trait change until the wait lands.
| strategy: polling_strategy_to_wire(strategy), | ||
| count, | ||
| auto_commit, | ||
| wait_timeout_us, |
There was a problem hiding this comment.
group polls pick one assigned partition round-robin, so a wait here parks the consumer on that partition while the others may already have data. the group case needs a design answer before the field goes on the wire.
| } | ||
|
|
||
| /// Reject a non-zero wait timeout until active-server deferred waits are implemented. | ||
| async fn reject_deferred_poll<B, MJ, S, SB>( |
There was a problem hiding this comment.
this is the whole server side: log and deny. the issue asks for the wait itself - port the #3605 waiter to this server instead of stubbing.
| S: 'static, | ||
| SB: SuperblockStore + 'static, | ||
| { | ||
| if wire.wait_timeout_us != 0 { |
There was a problem hiding this comment.
dead check - handle_poll_messages already returned at line 2175 and the http wire hardcodes 0. drop it.
| } | ||
|
|
||
| #[iggy_harness(test_client_transport = [Tcp])] | ||
| async fn given_non_zero_wait_timeout_when_polling_should_reject_feature_unavailable( |
There was a problem hiding this comment.
this pins the stub, not a behavior anyone wants. it goes away the day the wait lands - drop it, or make it the real wait test.
| pos += 4; | ||
| let auto_commit = read_u8(buf, pos)? != 0; | ||
| pos += 1; | ||
| let wait_timeout_us = if buf.len() == pos { |
There was a problem hiding this comment.
presence is sniffed from the remaining length, so the next optional field has to repeat the trick. a flags byte or a version would age better.
| wait_timeout_us: u64, | ||
| } | ||
|
|
||
| fn duration_to_wait_timeout_us(wait_timeout: Duration) -> Result<u64, IggyError> { |
There was a problem hiding this comment.
sub-microsecond timeouts truncate to 0 and silently become an immediate poll. round up or reject.
Which issue does this PR address?
Closes #3470
Rationale
PollMessagesneeds a backward-compatible way for clients to request a bounded wait when no messages are available. Immediate polling remains unchanged for existing clients and for a zero timeout.What changed?
Empty
PollMessagesrequests can now carry a trailingwait_timeout_usfield; legacy requests decode it as zero, while partial trailing fields are rejected. The common, SDK, consumer-group, simulator, and HTTP-zero paths carry the value through the current tree.This is a clean rebuild after closed PR #3605. The active
core/serverpath currently rejects non-zero waits with typedFeatureUnavailableuntil a safe waiter/notifier implementation is designed. Nocore/server-ng, legacy server, benchmark markdown, or runbook files are included.Local Execution
cargo fmt --all— passedcargo clippy --all-targets --all-features -- -D warnings— passedcargo test -p iggy_binary_protocol poll_messages— 15 passedcargo test -p iggy_common wait_timeout— 2 passedcargo check -p iggy -p server -p simulator— passedcargo check -p integration --tests— passedcargo machete— passedcargo sort --workspace— passed; no changes neededtypos— passed./scripts/ci/license-headers.sh --check— passed with HawkEye 7git diff --check— passedprekis not installed in this environmentcargo build --workspacewas attempted but could not link in this x86_64-targeted macOS environment because the installed Homebrewxzandhwloclibraries are arm64. Full localcargo testis not claimed. Fresh GitHub CI run32720521140passed all 74 jobs after the rebase onto currentmaster.AI Usage
AI was used for code review, and test/CI orchestration. The changed code was reviewed and verified with the local checks above and GitHub CI; I can explain every line of the code if asked.