Skip to content

Commit b40230b

Browse files
committed
docs: update kitex v1.16.2 md
1 parent ac2ea27 commit b40230b

2 files changed

Lines changed: 22 additions & 50 deletions

File tree

content/en/blog/releases/Kitex/release-v0_16_2.md

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,23 @@ description: >
1919

2020
In previous versions, binary generic clients were bound to an IDL Service, requiring maintenance of a large number of clients. This version supports dynamically specifying the IDL Service Name per call, via the newly added `callopt.WithBinaryGenericIDLService(svcName)` / `streamcall.WithBinaryGenericIDLService(svcName)` call options, and the per-call configuration takes precedence over the configuration set at client initialization. Both Ping-Pong and streaming calls are supported. For details, see [Per-Call IDL Service Name](/docs/kitex/tutorials/advanced-feature/generic-call/basic_usage#per-call-idl-service-name).
2121

22-
2. **New In-Process LocalCaller: Supports Unary Local Invocation**
23-
24-
Added `server.LocalCaller` and `server.NewLocalCaller(caller string, svr Server) (LocalCaller, error)`, which can directly invoke unary methods registered on the Server within the same process. It reuses the Server's Middleware and Tracer, keeping behavior consistent with remote invocations. Streaming methods and generic services that rely on `ServiceInfo.GenericMethod` are rejected. The legacy `server.InvokeCaller` is deprecated.
25-
26-
3. **Recv Timeout Control for Streaming**
22+
2. **Recv Timeout Control for Streaming**
2723

2824
Added `streaming.TimeoutConfig` for fine-grained Recv timeout control on streaming APIs. A dedicated timeout can be configured, and the new `DisableCancelRemote` flag controls whether the remote stream is cascaded-cancelled after timeout. Two configuration entry points are provided:
2925
- Per-client: `client.WithStreamRecvTimeoutConfig(streaming.TimeoutConfig)`
3026
- Per-call: `streamcall.WithRecvTimeoutConfig(streaming.TimeoutConfig)`
3127

3228
When a Recv times out, a new error code `codes.RecvDeadlineExceeded` (value `17`) is returned together with the sentinel error `kerrors.ErrStreamingTimeout`, making timeout classification easier.
3329

34-
4. **Fine-Grained Streaming Event Tracing - StreamEventHandler**
30+
3. **Fine-Grained Streaming Event Tracing - StreamEventHandler**
3531

3632
A new event-callback mechanism, independent of the Tracer, can observe the core events of the streaming protocol layer (Stream start, Recv, Send, Recv Header, Stream finish), making it easy to build custom fine-grained streaming monitoring:
3733
- Client: `client.WithStreamEventHandler(rpcinfo.ClientStreamEventHandler)`
3834
- Server: `server.WithStreamEventHandler(rpcinfo.ServerStreamEventHandler)`
3935

4036
New event types `stats.StreamStart`, `stats.StreamRecvHeader`, and `stats.StreamFinish` are also added. For details, see [StreamX Detailed Stream Event Tracing](/docs/kitex/tutorials/basic-feature/streamx/streamx_event_handler).
4137

42-
### **Feature/Experience Optimization**
38+
### **Feature/Performance Optimization**
4339
1. **Kitex gRPC: Memory Optimization and Connection Leak Fixes**
4440
- **HTTP/2 Write Buffer Reuse and Framer-Level Pooling**: Supports per-connection pooling and reuse of write buffers, reducing memory usage for idle connections, suitable for scenarios where the service needs to directly handle a large number of gRPC connections. Use `client.WithGRPCReuseWriteBuffer` / `server.WithGRPCReuseWriteBuffer` to enable it, and further enable framer-level pooling via `ReuseWriteBufferConfig.EnableReuseHTTP2FramerBuffer`.
4541
- **Client-Side Cancel Object Allocation Optimization**: Reduces object allocations for unified cancel on the gRPC client side, avoiding excessive allocations in gateway scenarios where cancel operations are frequent.
@@ -55,11 +51,7 @@ description: >
5551

5652
4. **RPCInfo Field Inlining**
5753

58-
Added `rpcinfo.NewRPCInfoWithInlineFields() RPCInfo`, which returns an RPCInfo with inlined sub-objects, reducing per-request pool gets and allocations. Server hot paths and LocalCaller both adopt this inlining approach.
59-
60-
5. **Load Balance: Consistent-Hash Switched to maphash**
61-
62-
The consistent-hash key/node hashing in `consistBalancer` replaces `github.com/bytedance/gopkg/util/xxhash3` with `hash/maphash`. Note that `hash/maphash` uses a per-process random seed, so hash values differ across client replicas and restarts.
54+
Added `rpcinfo.NewRPCInfoWithInlineFields() RPCInfo`, which returns an RPCInfo with inlined sub-objects, reducing per-request pool gets and allocations. Server hot paths adopt this inlining approach, improving request handling performance.
6355

6456
### **Bug Fixes**
6557
1. **Streaming-Related Fixes**
@@ -68,7 +60,7 @@ description: >
6860

6961
2. **Other Fixes**
7062
- **rpcTimeout Ticker Leak Fix** (extremely rare): Closed the ticker in the `rpcTimeout` pool to prevent resource leaks. Most online scenarios are unaffected; this issue is only noticeable in scenarios with extremely low QPS and short processing time for the API.
71-
- **Panic Caused by Writing Elements of Different Types into Container Fields in Generic Calls** (very rare): Writing elements of different types into the same container field could cause a panic. For example, if the field itself is `[]uint8`, the first input may be `uint8` while the second input may be `string`. After the fix, the writer is resolved per element instead of caching the first element's writer, and a type mismatch now returns an error.
63+
- **Panic Caused by Writing Elements of Different Types into Container Fields in Generic Calls** (very rare): Writing elements of different types into the same container field could cause a panic. For example, if the field itself is `[]uint8`, the first input may be `uint8` while the second input may be `string`. After the fix, an error is returned instead of panic.
7264

7365
### **Special Changes - May Affect a Small Number of Services**
7466
> Mainly Breaking Changes and API deprecations. No impact on the vast majority of users; users with special dependencies should pay attention.
@@ -83,6 +75,10 @@ description: >
8375

8476
The `onClose` / `onGoAway` callbacks now fire after the transport transitions to closing/draining and after `http2Client.mu` is released. Callers relying on the old ordering should migrate to `grpc.NewClientTransportWithConfig`.
8577

78+
3. **`consistBalancer` Consistent-Hash Algorithm Switched** (#1924)
79+
80+
The consistent-hash key/node hashing in `consistBalancer` replaces `github.com/bytedance/gopkg/util/xxhash3` with `hash/maphash`. Because `hash/maphash` uses a per-process random seed, hash values **differ across client replicas and restarts**.
81+
8682
#### Deprecations
8783
> APIs are only marked as deprecated in this version; they still work, but please migrate to the new APIs at your earliest convenience.
8884
@@ -93,23 +89,13 @@ description: >
9389

9490
See [Connection Multiplexing](/docs/kitex/tutorials/basic-feature/connection_type#connection-multiplexing) for the rationale.
9591

96-
2. **`server.InvokeCaller` Deprecated** (#1930)
97-
98-
Use the newly added `server.LocalCaller` instead.
99-
100-
3. **`grpc.NewClientTransport` Deprecated** (#1945)
101-
102-
Use `grpc.NewClientTransportWithConfig(ctx, conn, opts, grpc.ClientConfig)` instead. The new entry's `OnClose` / `OnGoAway` callbacks receive context and transport parameters.
103-
104-
4. **`kerrors.ErrRPCFinish` Restored as Deprecated Symbol** (#1953)
92+
2. **`kerrors.ErrRPCFinish` Restored as Deprecated Symbol** (#1953)
10593

10694
v0.16.2 restores this API as a deprecated symbol for backward compatibility with pre-v0.15 code.
10795

108-
5. **Streaming-Related API Deprecations**
96+
3. **Streaming-Related API Deprecations**
10997
- `client.WithStreamRecvTimeout` is deprecated; use `client.WithStreamRecvTimeoutConfig` instead (#1911)
11098
- `streamcall.WithRecvTimeout` is deprecated; use `streamcall.WithRecvTimeoutConfig` instead (#1911)
111-
- `rpcinfo.TraceController.GetStreamEventHandler()` is deprecated; use `TraceController.Handle*` methods instead (#1905)
112-
- `internal/stream.StreamEventHandler` is deprecated; use `rpcinfo.ClientStreamEventHandler` / `rpcinfo.ServerStreamEventHandler` instead (#1905)
11399

114100
## **Full Change**
115101

content/zh/blog/releases/Kitex/release-v0_16_2.md

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,23 @@ description: >
1919

2020
旧版二进制泛化 Client 与 IDL Service 绑定,需要维护大量 Client。本版本支持请求时动态指定 IDL Service Name,通过新增的 `callopt.WithBinaryGenericIDLService(svcName)` / `streamcall.WithBinaryGenericIDLService(svcName)` 调用选项指定,且调用维度的配置优先级更高。Ping-Pong 和流式调用均支持,详见 [动态指定 IDL Service Name](/zh/docs/kitex/tutorials/advanced-feature/generic-call/basic_usage#动态指定-idl-service-name)
2121

22-
2. **新增进程内 LocalCaller:支持 unary 本地调用**
23-
24-
新增 `server.LocalCaller``server.NewLocalCaller(caller string, svr Server) (LocalCaller, error)`,可在进程内直接调用 Server 注册的 unary 方法。复用 Server 的 Middleware、Tracer,行为与远程调用一致;流式方法和依赖 `ServiceInfo.GenericMethod` 的 generic service 会被拒绝。旧的 `server.InvokeCaller` 标记为废弃。
25-
26-
3. **流式接口 Recv 超时控制**
22+
2. **流式接口 Recv 超时控制**
2723

2824
新增 `streaming.TimeoutConfig`,支持对流式接口 Recv 进行细粒度超时控制,可单独配置超时时间,并通过 `DisableCancelRemote` 控制超时后是否级联取消远端流。提供两种配置入口:
2925
- Client 维度:`client.WithStreamRecvTimeoutConfig(streaming.TimeoutConfig)`
3026
- 单次调用维度:`streamcall.WithRecvTimeoutConfig(streaming.TimeoutConfig)`
3127

3228
Recv 超时返回新错误码 `codes.RecvDeadlineExceeded`(值为 `17`)以及哨兵错误 `kerrors.ErrStreamingTimeout`,便于区分超时类型。
3329

34-
4. **流式细粒度事件追踪 - StreamEventHandler**
30+
3. **流式细粒度事件追踪 - StreamEventHandler**
3531

3632
新增独立于 Tracer 的流式事件回调机制,可以感知流式协议层面的核心 Event(Stream 开始、Recv、Send、Recv Header、Stream 结束),便于定制细粒度的流式监控:
3733
- Client:`client.WithStreamEventHandler(rpcinfo.ClientStreamEventHandler)`
3834
- Server:`server.WithStreamEventHandler(rpcinfo.ServerStreamEventHandler)`
3935

4036
同时新增 `stats.StreamStart``stats.StreamRecvHeader``stats.StreamFinish` 事件类型。详见 [StreamX 流式细粒度事件追踪](/zh/docs/kitex/tutorials/basic-feature/streamx/streamx_event_handler)
4137

42-
### **功能/体验优化**
38+
### **功能/性能优化**
4339
1. **Kitex gRPC:内存优化与连接泄漏修复**
4440
- **HTTP/2 write buffer 复用与 framer 池化**:支持连接维度的 write buffer 池化复用,降低空闲连接内存占用,适用于直接承接大量 gRPC 连接的场景。通过 `client.WithGRPCReuseWriteBuffer` / `server.WithGRPCReuseWriteBuffer` 启用,并在 `ReuseWriteBufferConfig.EnableReuseHTTP2FramerBuffer` 中进一步启用 framer 层的池化。
4541
- **Client 侧 cancel 对象分配优化**:减少 gRPC client 在统一 cancel 场景下的对象分配,避免网关等需要频繁 cancel 的场景分配大量对象。
@@ -55,11 +51,7 @@ description: >
5551

5652
4. **RPCInfo 字段内联**
5753

58-
新增 `rpcinfo.NewRPCInfoWithInlineFields() RPCInfo`,返回带内联子对象的 RPCInfo,减少每次请求的 pool get 与对象分配;server 热点路径与 LocalCaller 均采用该内联方式。
59-
60-
5. **loadbalance:consistent-hash 使用 maphash**
61-
62-
`consistBalancer` 的 consistent-hash key/node 哈希将 `github.com/bytedance/gopkg/util/xxhash3` 替换为 `hash/maphash`。注意 `hash/maphash` 在每个进程使用随机种子,hash 值会在不同 client 副本和重启之间不同。
54+
新增 `rpcinfo.NewRPCInfoWithInlineFields() RPCInfo`,返回带内联子对象的 RPCInfo,减少每次请求的 pool get 与对象分配;server 热点路径采用该内联方式,提升请求处理性能。
6355

6456
### **问题修复**
6557
1. **流式相关问题修复**
@@ -68,7 +60,7 @@ description: >
6860

6961
2. **其他问题修复**
7062
- **rpcTimeout ticker 泄漏修复**(极小概率):关闭 rpcTimeout pool 中的 ticker,防止资源泄漏。线上绝大部分场景无问题,只在 QPS 极低且接口处理时间较短的场景会感知到。
71-
- **泛化调用容器字段写入不同类型元素 panic**(小概率):当某个容器字段被写入了不同类型的元素时会 panic(例如字段本身是 `[]uint8`,第一个传入 `uint8`,第二个却传入 `string`)。修复后按元素逐个解析 writer 而非缓存第一个 writer,并对类型不匹配返回错误
63+
- **泛化调用容器字段写入不同类型元素 panic**(小概率):当某个容器字段被写入了不同类型的元素时会 panic(例如字段本身是 `[]uint8`,第一个传入 `uint8`,第二个却传入 `string`)。修复后返回错误而不是直接 panic
7264

7365
### **特殊变更 - 少数服务可能会有影响**
7466
> 主要为 Breaking Changes 与接口废弃,对绝大部分用户无影响,请有特殊依赖的用户关注。
@@ -83,6 +75,10 @@ description: >
8375

8476
`onClose` / `onGoAway` 回调改为在 transport 状态转换为 closing/draining 并释放 `http2Client.mu` 之后触发。依赖旧时序的调用方请迁移至 `grpc.NewClientTransportWithConfig`
8577

78+
3. **`consistBalancer` 一致性哈希算法替换**#1924
79+
80+
`consistBalancer` 的 consistent-hash key/node 哈希将 `github.com/bytedance/gopkg/util/xxhash3` 替换为 `hash/maphash``hash/maphash` 在每个进程使用随机种子,hash 值会在**不同 client 副本和重启之间不同**
81+
8682
#### 接口废弃
8783
> 当前版本仅标记废弃,仍保留可用,请及时迁移到新接口。
8884
@@ -93,23 +89,13 @@ description: >
9389

9490
废弃原因详见 [连接多路复用](/zh/docs/kitex/tutorials/basic-feature/connection_type#连接多路复用)
9591

96-
2. **`server.InvokeCaller` 废弃**#1930
97-
98-
使用本版本新增的 `server.LocalCaller` 替代。
99-
100-
3. **`grpc.NewClientTransport` 废弃**#1945
101-
102-
使用 `grpc.NewClientTransportWithConfig(ctx, conn, opts, grpc.ClientConfig)` 替代。新入口的 `OnClose` / `OnGoAway` 回调接收 context 与 transport 参数。
103-
104-
4. **`kerrors.ErrRPCFinish` 恢复为废弃符号**#1953
92+
2. **`kerrors.ErrRPCFinish` 恢复为废弃符号**#1953
10593

10694
v0.16.2 重新加回该 API 作为废弃符号,便于 pre-v0.15 代码继续编译。
10795

108-
5. **流式相关接口废弃**
96+
3. **流式相关接口废弃**
10997
- `client.WithStreamRecvTimeout` 废弃,使用 `client.WithStreamRecvTimeoutConfig` 替代(#1911
11098
- `streamcall.WithRecvTimeout` 废弃,使用 `streamcall.WithRecvTimeoutConfig` 替代(#1911
111-
- `rpcinfo.TraceController.GetStreamEventHandler()` 废弃,使用 `TraceController.Handle*` 方法替代(#1905
112-
- `internal/stream.StreamEventHandler` 类型废弃,使用 `rpcinfo.ClientStreamEventHandler` / `rpcinfo.ServerStreamEventHandler` 替代(#1905
11399

114100
## **详细变更**
115101

0 commit comments

Comments
 (0)