Repository navigation
M3a: Saga, Event-Driven Architecture, Containerization - #4
Merged
Merged
Conversation
…d containers - Pattern 8: checkout is an orchestrated saga in the order service: price (catalog), hold stock (inventory), charge (payment), confirm. A decline, an open breaker or a payment error releases the hold; if that call fails, StockReleaseRequested goes through the outbox. Steps in saga_step. - Pattern 7: OrderConfirmed is written to an outbox table in the same transaction as the order; a relay publishes to the Redis Stream shop.events; inventory consumes it in its own group and turns the hold into a sale, deduping on event id. A demo switch disconnects the bus. - Pattern 9: multi-stage Dockerfiles running as uid 10001, .dockerignore everywhere (local venvs were being uploaded), GIT_SHA build arg, CI builds and runs all 7 images for linux/amd64. - Fixes found on the way: two order replicas racing to create tables; Flask's reloader watcher process running a second, unswitchable outbox relay; 18 catalog products with no stock record. - make run starts an in-memory Redis on 6390. Contracts add order -> inventory and a declined charge. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Two-axis review (Matt Pocock code-review: standards + spec). Each fix below has a failing test first, except the two concurrency fixes (noted). - Event reader: one failing event no longer blocks the ones behind it; it is retried between new reads and moved to shop.events.dead after 5 tries (Reader.read_once, tested with a fake Redis). - Checkout: one saga per order at a time (checkout_lock, expires after 60 s), so a double click cannot hold stock or charge twice. - Every saga step publishes an event: StockReserved, PaymentCharged, OrderConfirmed, CheckoutFailed. - A timed-out stock hold is released through the bus (StockReleaseRequested). - A payment timeout no longer tells the shopper "nothing was charged". - The decline switch needs CHAOS_ENABLED=1; restock input is validated (400, 404). - Concurrency, no unit test (needs 2 real DB sessions): stock rows locked in product id order; a duplicate hold insert returns the existing hold. - Tidy-ups: seed_missing_stock rename, shared failure path in Saga.fail, imports, one fewer call. - README, CLAUDE.md, .env.example and PLAN.md updated; build preference recorded in CLAUDE.md. Co-Authored-By: Claude Opus 5.5 <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.
Milestone M3a of docs/PLAN.md (see "M3 review"). 11 of 12 patterns are now live. CI-CD and the Azure run are M3b.
Patterns
shop.events.OrderConfirmed. It dedupes on the event id, and a failing event goes to a dead-letter stream after 5 tries..dockerignore. Before this, local virtualenvs were uploaded with every cloud build.GIT_SHAbuild arg.linux/amd64, starts it, checks/health, and fails if it runs as root.Found and fixed during the click-through
Code review (Matt Pocock code-review: standards and spec)
11 standards findings and 8 spec findings. All the bugs and behaviour gaps are fixed, each with a failing test first, except 2 concurrency fixes that need real concurrent database sessions (see the commit message). SHA tags on the Azure build path and the image size on the page move to M3b, as recorded in PLAN.md.
Tests
p07,p08andp09are indocs/screenshots/.Notes
brew install redis.make runstarts it in memory on port 6390 and stops it with the stack.🤖 Generated with Claude Code