Skip to content

feat(examples): demonstrate competing inventory lifecycles - #12

Merged
yordis merged 1 commit into
mainfrom
yordis/feat-competing-reservations-example
Sep 8, 2026
Merged

feat(examples): demonstrate competing inventory lifecycles#12
yordis merged 1 commit into
mainfrom
yordis/feat-competing-reservations-example

Conversation

@yordis

@yordis yordis commented Sep 8, 2026

Copy link
Copy Markdown
Member
  • Concurrent inventory workflows need a concrete proof that optimistic concurrency serializes decisions without turning event IDs into global uniqueness constraints.
  • Multiple reserve and release cycles make distinct operation identity and durable retry boundaries observable after the stream advances.

Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
@cursor

cursor Bot commented Sep 8, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Changes are limited to an example and integration tests; no production client or runtime behavior is modified.

Overview
Expands the idempotent reservation example from a single-client retry into a two-checkout race on inventory of 1, using expected stream revision so only one reserve wins and the other gets WrongExpectedVersion.

The example now models reserve → release lifecycles with distinct OperationId (event id) and ReservationId, stream folding via read_inventory, and the loser re-reading the stream before appending again. After several successful writes, it replays six stale appends (original revision + same event id) and asserts WriteResult.position matches the first successful write—showing idempotency is tied to revision + id, not a global unique event id.

Adds integration coverage in competing_reservations_are_serialized_and_retryable in idempotency.rs (same flow with fold_inventory and event-id ordering assertions) and registers it in the idempotency test suite.

Reviewed by Cursor Bugbot for commit 68f2be3. Bugbot is set up for automated code reviews on this repo. Configure here.

@coderabbitai

coderabbitai Bot commented Sep 8, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 3 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 6fdc1cfc-2467-46e7-bc5d-7544e5a1c224

📥 Commits

Reviewing files that changed from the base of the PR and between 87784f2 and 68f2be3.

📒 Files selected for processing (2)
  • examples/idempotent_reservation.rs
  • trogon-eventstore/tests/api/idempotency.rs

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@yordis
yordis merged commit 360931d into main Sep 8, 2026
8 checks passed
@sht-bot sht-bot mentioned this pull request Sep 8, 2026
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.

1 participant