feat: add v1alpha1 Consistency pattern for read-after-write#34
Conversation
PR SummaryLow Risk Overview Adds a dedicated doc ( Written by Cursor Bugbot for commit 7f0ac49. This will update automatically on new commits. Configure here. |
WalkthroughThis pull request introduces a read-after-write consistency pattern for CQRS and Event Sourcing systems. It adds a Protobuf definition file introducing Consistency, MinVersion, and ExactVersion messages, along with comprehensive documentation describing usage, implementation guidelines, and trade-offs. Changes
Sequence Diagram(s)sequenceDiagram
actor Client
participant Server
participant Projection
Client->>Server: Mutation request
Server->>Server: Process mutation
Server-->>Client: Response + stream_version
Client->>Server: Query + Consistency(stream_version)
Server->>Projection: Check projection.version
alt projection.version >= stream_version
Server-->>Client: Return result
else version mismatch
Server->>Server: Retry with backoff
Server->>Projection: Check projection.version again
Server-->>Client: Return result (after catch-up)
else timeout exceeded
Server-->>Client: Unavailable error
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
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 |
|
The latest Buf updates on your PR. Results from workflow Buf CI / buf (pull_request).
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
3f7790a to
0d24f95
Compare
Add trogon.consistency.v1alpha1 package for implementing read-after-write consistency in eventual consistency systems (CQRS/Event Sourcing). Features: - MinVersion mode: wait for projection >= required version (read-your-writes) - ExactVersion mode: wait for projection == required version (strict snapshots) - Configurable timeout_duration and delay_duration - Server-side retry logic with version checking - Comprehensive documentation with examples and trade-offs Inspired by SpiceDB's consistency patterns (at_least_as_fresh, at_exact_snapshot). Use case: Enable clients to immediately read their own writes despite projection lag in CQRS systems by specifying minimum version requirements from mutation responses. Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>

Add trogon.consistency.v1alpha1 package for implementing read-after-write
consistency in eventual consistency systems (CQRS/Event Sourcing).
Features:
Inspired by SpiceDB's consistency patterns (at_least_as_fresh, at_exact_snapshot).
Use case: Enable clients to immediately read their own writes despite
projection lag in CQRS systems by specifying minimum version requirements
from mutation responses.
Signed-off-by: Yordis Prieto yordis.prieto@gmail.com