Repository navigation
feat(example): add the ddk-mall reference application with the order context - #74
Merged
Merged
Conversation
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.
Background
DDK has thirteen starters and one small example with a single-table aggregate. Locks, scheduled jobs, reliable events and the operator context have never been used together in one business flow.
ddk-mallis the reference application that does this: place an order, reserve stock, pay, and cancel on timeout, across order, inventory and payment contexts. It is built in six steps; this PR is the first.Changes
ddk-examples/ddk-mall: one deployable application, one top-level package per bounded context, four layers inside each.platform: the customer identity comes from theX-Customer-Idheader through anOperatorResolver; the example has no login.docker-compose.ymlwith MySQL and amysqlprofile; the default profile runs on in-memory H2.Design decisions:
OrderRepositoryImpluses the repository extension points added in the previous PR for the order line table; the application layer never sees it.ProductCatalogport and are stored on the order line as a snapshot.ArchitectureTestadds a slices rule overorder,inventoryandpaymentnext to DDK's layer rules. It has nothing to check yet and starts to matter in step 2.One test runs against a real MySQL through
DdkContainers.mysql(): the migrations apply, an order round-trips with its lines, and a stale order cannot overwrite a newer one.背景
DDK 有 13 个 starter,却只有一个很小的示例,聚合也只对应一张表。聚合锁、定时任务、可靠事件、操作者上下文从来没有在同一个业务流程里一起用过。
ddk-mall就是做这件事的参考应用:下单、预占库存、支付、超时取消,跨订单、库存、支付三个上下文。它分六步建设,本 PR 是第一步。改动
ddk-examples/ddk-mall:一个可部署应用,每个限界上下文一个顶层包,内部是四层结构。platform:顾客身份通过OperatorResolver取自请求头X-Customer-Id,示例不做登录。docker-compose.yml(MySQL)与mysqlprofile;默认 profile 用内存 H2。包结构见上文。设计取舍:
OrderRepositoryImpl用上一个 PR 新增的仓储扩展点处理订单行表,应用层看不到它。ProductCatalog端口,并作为快照存在订单行上。ArchitectureTest在 DDK 的分层规则之外,加了一条针对order、inventory、payment的切片规则。现在还没有可检查的内容,第 2 步开始起作用。有一个测试通过
DdkContainers.mysql()连接真实的 MySQL:迁移脚本可以执行,订单连同订单行完整读写,过期的订单不能覆盖新的。