Repository navigation
feat(projectors): project runs into a Postgres event log without blocking append - #41
Merged
Merged
Conversation
…king append Durable Object projectors are scheduled with waitUntil after the log commits. postgresEventLog stores each non-ephemeral envelope and a run index with status, launch links, and tenant attributes, and can rebuild that sink from the log. Co-authored-by: Cursor <cursoragent@cursor.com>
…tements postgresEventLog issued one statement per event plus one per run-index change. A batch is now one multi-row event insert per 1,000 rows, one upsert for runs that started or finished, and one unnest update for runs that only gained events, all in one transaction. Index changes are folded per run first, with the same rules as the memory sink. New tests run the Postgres sink on PGlite through its socket server. They check that it matches the memory sink row for row, that it writes a fixed number of statements, and that a touch-only batch ignores unknown runs. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.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.
Problem and change
withProjectorspreviously ran delivery insideappend, adding projector latency to every run step. On Durable Objects, projector delivery is now scheduled withwaitUntilafter the append commits, soappendreturns when the primary log commits. The durable cursor still tracks delivery and retries failures on the next alarm or request.postgresEventLogadds a generic sink for all non-ephemeral events, keyed on(run_id, seq), and alooms_run_indextable containing run status, timestamps, parent and launch effect links, and indexed tenant/project/org columns for row-level security.rebuild(source)replays a run or the whole store from seq 1.Review notes
This branch branches from
main.postgresEventLogworks over Hyperdrive or direct Postgres connections.waitUntilexecution is covered by the@looms/projectorsscheduled delivery test and typechecked with Cloudflare Workers types.Checked with
bun x tsc -p packages/{projectors,cloudflare}/tsconfig.build.json --noEmit,bun x oxlint --deny-warningson changed files, andbun test srcinpackages/projectorsandpackages/cloudflare.bun run verifywas not run.Existing contributor checklist
bun run verifypasses@swirls/loomsbehavior changes (bun run changeset)Made with Cursor