feat(runtime): dispatcher 薄域注册表接缝 — ADR-0076 D11 步骤③ PR-1 (#2462)#3491
Merged
Conversation
…er — ADR-0076 D11 step ③ PR-1 (#2462) dispatch() routed every domain through one hand-written startsWith if-chain and every handler lived on the dispatcher class — the "god implementation on a clean port" shape D11 calls out. This is the decomposition seam, cut deliberately small: - DomainHandlerRegistry: first-match {prefix, match, methods, handler} table, no wildcards/params/middleware — only "which domain owns this path". Matching is FAITHFUL to the legacy chain, rough edges included (bare startsWith also matching '/i18nxx' is preserved, not fixed). - dispatch() consults the registry before the legacy chain; the four seeded prefixes are disjoint from every remaining branch, so registry-first is order-equivalent. - Seeded four builtin domains demonstrating the three handler shapes: /health + /ready (no service dependency), /analytics (service bridge; fallback-vs-replace semantics stay in the service layer per D10/D12), /i18n (optional service, in-handler 501). - registerDomainHandler() is the public seam follow-up domain PRs use to move handler bodies + registration ownership into owning service packages (service-absence semantics decided per-domain there, with D12 discovery honesty). Verified: 11 new seam tests; runtime 610 tests green; http-conformance 41 cross-adapter assertions green; 25-package dependent closure builds with DTS. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
📓 Docs Drift CheckThis PR changes 1 package(s): 17 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
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.
动机(#2462 D11 步骤③,系列第一刀)
dispatch()把所有域塞在一条手写startsWithif 链里、所有 handler 挂在 dispatcher 类上(4.7k 行且 30 天 34 次提交还在长)——正是 ADR-0076 D11 点名的"干净 port + 上帝实现"。本 PR 落下拆解接缝,刀口刻意切小。改动
DomainHandlerRegistry:first-match{prefix, match, methods, handler}表。无通配/无参数/无中间件——只回答"这个路径归哪个域"。匹配语义保真复刻旧 if 链,毛边照留(裸startsWith会匹配/i18nxx的行为原样保留,修毛边不是接缝的职责)。dispatch()在旧链之前查表;四个种子前缀与其余分支前缀互斥,前置查表与原链位置顺序等价。/health+/ready(无服务依赖探针)、/analytics(服务桥——fallback vs replace 语义留在服务层,见 D10/D12,故其注册权暂留 dispatcher)、/i18n(可选服务、handler 内 501 自兜)。registerDomainHandler()公共缝:后续每域一个 PR 把 handler 体 + 注册权移交所属服务包(缺席语义 501→404 在那时逐域决定,配合 D12 honest capabilities 的 discovery 联动)。迁移纪律(注册表先行、代码后搬、归属最后)
本 PR handler 体不动(仍是 dispatcher 方法,注册项只是包装)——diff 最小、行为零变化最可证。后续 PR 逐域搬体移权,全部迁完后
createHonoAppcatch-all 退役(解锁 D11 步骤①)。验证
/ready503 分支与/i18n501 / 公共缝注册命中)。@objectstack/http-conformance跨适配器 41 断言绿;--force重建 runtime 及 25 个下游包含 DTS 全绿。关联 #2462(D11 步骤③ PR-1)。与 #3487(D11 步骤④)相互独立、可并行评审。
🤖 Generated with Claude Code