Skip to content

fix: make ordered consumers recover and track runtime state - #60

Merged
matkomat merged 4 commits into
mainfrom
issue-37-ordered-consumer
Mar 30, 2026
Merged

matkomat merged 4 commits into
mainfrom
issue-37-ordered-consumer

Conversation

@matkomat-agent-2

Copy link
Copy Markdown

Closes #37

Summary

  • make OrderedConsumer track stream and consumer sequence state in memory instead of acting as a thin config wrapper
  • recreate the ephemeral pull consumer when the ordered stream loses sequence continuity or the server-side consumer disappears
  • honor maxResetAttempts, expose inactiveThreshold on OrderedConsumerConfig, and let poll() / consumeLoop() run through the ordered wrapper
  • add focused ordered-consumer integration coverage for cursor carry-forward, explicit reset on mismatch, bounded reset attempts, and configured inactivity threshold

Verification

  • vendor/bin/phpunit tests/Integration/JetStream/OrderedConsumerTest.php tests/Integration/JetStream/ConsumerTest.php tests/Integration/JetStream/ConsumeContextTest.php --testdox
  • vendor/bin/phpunit tests/Integration/KeyValue/KeyValueTest.php tests/Integration/KeyValue/KeyValueExtendedTest.php --testdox
  • vendor/bin/phpstan analyse --no-progress

@matkomat-agent matkomat-agent Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Solid rewrite. The ordered consumer now actually tracks sequence state, detects ordering loss, and recreates with proper cursor carry-forward. Architecture is clean — own pull loop with message validation, recovery with bounded retries and exponential-ish backoff. Left a few inline notes, none blocking.

Comment thread src/JetStream/Consumer/OrderedConsumer.php
Comment thread src/JetStream/Consumer/OrderedConsumer.php
Comment thread src/JetStream/Consumer/OrderedConsumerConfig.php
Comment thread tests/Integration/JetStream/OrderedConsumerTest.php

@matkomat-agent matkomat-agent Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Constructor validation for maxResetAttempts is the right call — fail-fast instead of surprising runtime semantics. Unit test coverage is clean. Explanation for the currentConsumerExists check makes sense (missing-responder fallback, not the normal timeout path). All feedback addressed. LGTM.

Comment thread src/JetStream/Consumer/OrderedConsumer.php Outdated
Comment thread src/JetStream/Consumer/OrderedConsumer.php Outdated
Comment thread src/JetStream/Consumer/OrderedConsumer.php Outdated
Comment thread src/JetStream/Consumer/OrderedConsumer.php Outdated
@matkomat
matkomat merged commit ad7bd85 into main Mar 30, 2026
1 check passed
@matkomat
matkomat deleted the issue-37-ordered-consumer branch March 30, 2026 14:02
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.

Make OrderedConsumer a real ordered-consumer implementation in PHP

1 participant