feat(gateway): add List API with request-summary read model#226
Draft
albertywu wants to merge 2 commits into
Draft
feat(gateway): add List API with request-summary read model#226albertywu wants to merge 2 commits into
albertywu wants to merge 2 commits into
Conversation
Add a queue-scoped, time-windowed List RPC to the gateway, served from a new gateway-owned request-summary read model rather than by scanning and reconciling the append-only request log per request. - entity: RequestSummary, plus queue + change URIs on RequestLog, QueueFromRequestID parse helper, and IsKnownRequestStatus allow-list for filter validation. - storage: RequestSummaryStore (page-in/page-out List with a stable newest-started-first cursor; UpsertFromLog guarded merge) and mysql impl + schema; queue/change_uri columns on request_log. - core/request: PersistLog helper that pairs RequestLogStore.Insert with a guarded summary upsert, wired into Land, Cancel, and the log sink so all three write paths update both views through one helper. - gateway: ListController + List RPC (proto + generated code) and wiring. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The request-summary store was the only store using a database transaction (BeginTx + SELECT ... FOR UPDATE + Commit), which this repo forbids in favor of optimistic concurrency. Replace it with the same optimistic-locking pattern as requestStore.UpdateState: read the summary unlocked, merge the incoming log in memory, then write back with a conditional update guarded by a new row version column. A concurrent writer (another gateway write path or a redelivered log event) loses the CAS, and the caller re-reads and re-merges. Merges are monotonic and idempotent, so the bounded loop converges; exhausting it surfaces as storage.ErrVersionMismatch. - schema: add optimistic-lock version column to request_summary. - update is now a pure conditional write taking oldVersion/newVersion; insert returns inserted=false on a duplicate-key race so the caller retries into the merge path. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add a queue-scoped, time-windowed List RPC to the gateway, served from a
new gateway-owned request-summary read model rather than by scanning and
reconciling the append-only request log per request.
QueueFromRequestID parse helper, and IsKnownRequestStatus allow-list
for filter validation.
newest-started-first cursor; UpsertFromLog guarded merge) and mysql impl
guarded summary upsert, wired into Land, Cancel, and the log sink so all
three write paths update both views through one helper.
Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com
Test Plan
Issues
Stack