fix(api-gateway): harden remote lifecycle and recovery

This commit is contained in:
imccyu
2026-08-07 21:47:17 +08:00
parent e89d078819
commit 686ee5b3f6
21 files changed
+218 -34

No files matched your search

+2 -2
View File
@@ -2,5 +2,5 @@
# side as of the last confirmed-consistent state. Both languages carry equal authority;
# after editing either side, bring the other along and re-record with:
# pnpm run verify-translation-pairing --write packages/typert/type-meta/README.md
README.md: b394c843409e840b75bbb08b128614379e528001
README.zh.md: 5bd9bb18289a0320e0603d8b373e60d7f1e3c7e5
README.md: a76169742cb78d0d19814bcd0f978c71036a5a1c
README.zh.md: 6f2d2fd6e241441fae8102c0639608e9b27b9bec
+1 -1
View File
@@ -20,7 +20,7 @@ Decorator initializers retain markers in a module-private `WeakMap` keyed by the
Business packages extend `TypeRTLookupMap` and `TypeRTContextMap` to associate Host objects or scoped Contexts with their wire identities. Generated artifacts extend `TypeRTRemoteMap`, `TypeRTRemoteContextMap`, and `TypeRTRemoteNamespaceMap` so Client imports expose only selected Remote methods. `InvocationDescriptor` is the shared runtime form consumed by the registry, Gateway, and Client API.
Lookup and Context packages own both sides of their contract: declaration merging supplies the static association, while runtime providers register identity resolution with `ctx.typert`. A lookup provider supplies the stable declaration and default resolver, while Host composition may separately configure a synchronous or asynchronous resolver; policy rejections may use `TypeRTLookupFailure` to carry a failure value owned by the boundary adapter. Strict codecs carry generated schemas; `src-json` codecs identify the weaker source-launch path.
Lookup and Context packages own both sides of their contract: declaration merging supplies the static association, while runtime providers register identity resolution with `ctx.typert`. A lookup or Host Context provider supplies the stable declaration and default resolver, while Host composition may separately configure a synchronous or asynchronous resolver; policy rejections may use `TypeRTLookupFailure` to carry a failure value owned by the boundary adapter. Strict codecs carry generated schemas; `src-json` codecs identify the weaker source-launch path.
## Model Experience
+1 -1
View File
@@ -20,7 +20,7 @@ Host 方法通过将 `signal: AbortSignal` 声明为最后一个参数来启用
业务包扩展 `TypeRTLookupMap``TypeRTContextMap`,以关联 Host 对象或作用域 Context 与其协议身份。生成的产物扩展 `TypeRTRemoteMap``TypeRTRemoteContextMap``TypeRTRemoteNamespaceMap`,使 Client 导入后仅暴露选定的 Remote 方法。`InvocationDescriptor` 是供注册表、Gateway 和 Client API 使用的共享运行时形式。
查找包与 Context 包同时负责其契约的两侧:声明合并提供静态关联,运行时提供方则向 `ctx.typert` 注册身份解析。lookup provider 提供稳定声明与默认 resolver,Host 组合可以另行配置同步或异步 resolver;策略拒绝可用 `TypeRTLookupFailure` 携带由边界适配器拥有的失败值。严格编解码器携带生成的 schema;`src-json` 编解码器标识约束更弱的源码启动路径。
查找包与 Context 包同时负责其契约的两侧:声明合并提供静态关联,运行时提供方则向 `ctx.typert` 注册身份解析。lookup 或 Host Context provider 提供稳定声明与默认 resolver,Host 组合可以另行配置同步或异步 resolver;策略拒绝可用 `TypeRTLookupFailure` 携带由边界适配器拥有的失败值。严格编解码器携带生成的 schema;`src-json` 编解码器标识约束更弱的源码启动路径。
## 模型体验
+1
View File
@@ -50,6 +50,7 @@ export type {
TypeRTContextWire,
TypeRTDisposer,
TypeRTHostContextProvider,
TypeRTHostContextResolver,
TypeRTLocalRegistry,
TypeRTLookup,
TypeRTLookupDefinition,
+17 -1
View File
@@ -238,9 +238,14 @@ export interface TypeRTHostContextProvider<Wire = unknown> {
* @param id - validated wire identity.
* @returns the scoped Context, or `undefined` when unavailable.
*/
resolve(id: Wire): Context | undefined
resolve(id: Wire): Context | undefined | Promise<Context | undefined>
}
/** Composition-owned resolver replacing one Host Context provider's default lookup policy. */
export type TypeRTHostContextResolver<Wire = unknown> = (
id: Wire,
) => Context | undefined | Promise<Context | undefined>
/** Client resolver for the identity carried by the calling scoped Context. */
export interface TypeRTClientContextBinder<Wire = unknown> {
/**
@@ -367,6 +372,17 @@ export interface TypeRTContextRegistry {
key: K,
provider: TypeRTHostContextProvider<TypeRTContextWire<TypeRTContextMap[K]>>,
): TypeRTDisposer
/**
* Override one Host Context key's identity policy for the calling fiber.
* Configuration may precede provider registration and restores the provider's default resolver on disposal.
* @param key - merge-declared Context key.
* @param resolver - composition-owned resolver used by every Host Context lookup of this key.
* @returns disposer restoring the provider's default resolver.
*/
configureHost<K extends StringKeyOf<TypeRTContextMap>>(
key: K,
resolver: TypeRTHostContextResolver<TypeRTContextWire<TypeRTContextMap[K]>>,
): TypeRTDisposer
/**
* Register a Client Context identity binder.
* @param key - merge-declared Context key.