feat(typert): propagate Remote cancellation

This commit is contained in:
imccyu
2026-08-06 18:13:15 +08:00
parent 9b63d72c94
commit 22bec5e63f
28 changed files with 280 additions and 66 deletions

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 docs/core-data-structures/typert.md
typert.md: 9f5c63fc554a43fd0248ed08a64dcff566c83b58
typert.zh.md: 2b74c8325a510ba39d134fa6d463dab273239772
typert.md: da6e229ff6a2300c36f5734ad05c621a5e63082d
typert.zh.md: b3b0e8897756b5b4f9b645522cc5a1b27eac1d33

View File

@@ -38,7 +38,7 @@ interface TypeRTLookupDefinition {
## Invocation descriptors
An `InvocationDescriptor` is local reflection, not a wire message. Host and consumer builds generate corresponding descriptors; the request sends only the endpoint and named `args`. Strict codecs carry generated schemas, while SRC codecs enforce JSON-safe values without structural type recovery.
An `InvocationDescriptor` is local reflection, not a wire message. Host and consumer builds generate corresponding descriptors; the request sends only the endpoint and named `args`. Strict codecs carry generated schemas, while SRC codecs enforce JSON-safe values without structural type recovery. Cancellation is an out-of-band carrier signal injected after business parameters and never enters `args`.
```ts type-equiv
/** Codec attached to one invocation parameter or result. */
@@ -100,6 +100,11 @@ interface InvocationDescriptor {
}
/** Ordered business parameters. */
readonly parameters: readonly InvocationParameterDescriptor[]
/** Transport cancellation injected after business parameters instead of entering wire args. */
readonly cancellation?: {
/** Reserved final Host method parameter. */
readonly parameter: 'signal'
}
/** Codec for the resolved method result. */
readonly result: TypeRTCodec
/** Source declaration used only for diagnostics. */
@@ -130,7 +135,7 @@ interface TypeRTRemoteNamespaceMap {}
## Host Gateway
Connection decodes its carrier envelope before calling `ctx.typertGateway`. The request carries exact named wire fields; infrastructure and boundary failures use the Gateway's in-process error taxonomy, although the current RPC adapter folds them into the transport's `internal` error code.
Connection decodes its carrier envelope before calling `ctx.typertGateway`. The request carries exact named wire fields and the carrier's cancellation signal separately; infrastructure and boundary failures use the Gateway's in-process error taxonomy, although the current RPC adapter folds them into the transport's `internal` error code.
```ts type-equiv
/** One Remote method request after a carrier has decoded its envelope. */
@@ -141,6 +146,8 @@ interface InvokeRemoteRequest {
readonly method: string
/** Named wire values; fields must exactly match the descriptor. */
readonly args: Readonly<Record<string, unknown>>
/** Carrier or direct-caller cancellation injected only into cancellation-aware methods. */
readonly signal?: AbortSignal
}
```

View File

@@ -38,7 +38,7 @@ interface TypeRTLookupDefinition {
## 调用 descriptor
`InvocationDescriptor` 是本地反射信息,不是 wire message。Host 与消费方构建会生成彼此对应的 descriptor请求只发送 endpoint 与具名 `args`。strict codec 携带生成的 schemaSRC codec 则在不恢复结构类型的前提下强制要求 JSON 安全值。
`InvocationDescriptor` 是本地反射信息,不是 wire message。Host 与消费方构建会生成彼此对应的 descriptor请求只发送 endpoint 与具名 `args`。strict codec 携带生成的 schemaSRC codec 则在不恢复结构类型的前提下强制要求 JSON 安全值。取消通过带外 carrier signal 表达:它在业务参数之后注入,绝不进入 `args`。
```ts type-equiv
/** Codec attached to one invocation parameter or result. */
@@ -100,6 +100,11 @@ interface InvocationDescriptor {
}
/** Ordered business parameters. */
readonly parameters: readonly InvocationParameterDescriptor[]
/** Transport cancellation injected after business parameters instead of entering wire args. */
readonly cancellation?: {
/** Reserved final Host method parameter. */
readonly parameter: 'signal'
}
/** Codec for the resolved method result. */
readonly result: TypeRTCodec
/** Source declaration used only for diagnostics. */
@@ -130,7 +135,7 @@ interface TypeRTRemoteNamespaceMap {}
## Host Gateway
Connection 会先解码 carrier envelope再调用 `ctx.typertGateway`。请求携带精确的具名 wire 字段;基础设施与边界失败使用 Gateway 的进程内错误分类体系,但当前 RPC 适配器会把这些错误折叠为传输层的 `internal` 错误码。
Connection 会先解码 carrier envelope再调用 `ctx.typertGateway`。请求精确的具名 wire 字段与 carrier 的取消 signal 分开携带;基础设施与边界失败使用 Gateway 的进程内错误分类体系,但当前 RPC 适配器会把这些错误折叠为传输层的 `internal` 错误码。
```ts type-equiv
/** One Remote method request after a carrier has decoded its envelope. */
@@ -141,6 +146,8 @@ interface InvokeRemoteRequest {
readonly method: string
/** Named wire values; fields must exactly match the descriptor. */
readonly args: Readonly<Record<string, unknown>>
/** Carrier or direct-caller cancellation injected only into cancellation-aware methods. */
readonly signal?: AbortSignal
}
```