Skip to content

Commit 37f4e32

Browse files
authored
docs: Kitex v0.13.0 release (#1300)
1 parent b69c85d commit 37f4e32

15 files changed

+771
-198
lines changed
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
---
2+
title: "Kitex Release v0.13.0"
3+
linkTitle: "Release v0.13.0"
4+
projects: ["Kitex"]
5+
date: 2025-04-07
6+
description: >
7+
---
8+
9+
> We recommend upgrading directly to Kitex version v0.13.1, as we have fixed a potential Goroutine leak issue of the gRPC Client in v0.13.0.
10+
11+
## **Introduction to Key Changes**
12+
13+
### **New Features**
14+
1. **New streaming interface StreamX supports gRPC, existing Kitex gRPC users can migrate**
15+
16+
v0.12.0 released the StreamX interface to optimise the streaming experience, and supported the custom streaming protocol TTHeader Streaming, but did not support gRPC. So existing users could not migrate.
17+
18+
This version supports gRPC for StreamX, users can migrate to StreamX, and the Server side can be compatible with two streaming protocols at the same time. So there is no need to worry about protocol compatibility after interface migration.
19+
20+
In particular, when adapting gRPC with StreamX, we found that there are still some inconvenient problems. In order to bring a better experience of using the interface, we have adjusted the StreamX interface for the second time, which will affect the users who have already been using StreamX. We apologise for that.
21+
22+
User documentation: [StreamX User Documentation](/docs/kitex/tutorials/basic-feature/streamx)
23+
24+
2. **Prutal - Protobuf's non-generated code serialisation library**
25+
26+
[Prutal](https://github.com/cloudwego/prutal) is officially open source, on par with Thrift's [Frugal](https://github.com/cloudwego/frugal), and the new version of Kitex integrates Prutal by default.
27+
28+
Advantages:
29+
30+
- Minimized Code Product Size: Generating Only Structures, No Runtime Code
31+
32+
- Leveraging Reflection Optimization Similar to Frugal, Achieving Over 50% Speed Increase
33+
34+
- Generating Code Compatible with Existing Protobuf and Derivative Versions
35+
36+
User documentation: [Prutal](/docs/kitex/tutorials/code-gen/prutal)
37+
38+
### **Feature/Experience Optimization**
39+
1. **TTHeader Streaming: Support interface-level Recv timeout control**
40+
41+
In addition to the existing Client level, this release of TTHeader Streaming supports interface-level Recv timeout configuration, making configuration more flexible.
42+
43+
User documentation: [StreamX Timeout Control](/docs/kitex/tutorials/basic-feature/streamx/kitex+streamx+-+stream+timeout+control/)
44+
45+
2. **Default Thrift transport protocol changed from Buffered to Framed**
46+
47+
This change can leverage FastCodec for better performance.
48+
49+
### **Others**
50+
1. **Code Product Simplification**
51+
52+
- Kitex Tool would not generate the repeated verification code for Set data structure and the ```DeepEqual``` function for each structure by default.
53+
54+
- If you only want to restore```DeepEqual```, add```-thrift gen_deep_equal=true```to the generation command.
55+
56+
- If you want to restore the repeated verification of Set, add```-thrift validate_set=true, -thrift gen_deep_equal=true```to the generation command.
57+
58+
- Kitex Tool would not generate the Apache Codec related code by default.
59+
60+
- If you want to restore it, add```-thrift no_default_serdes=false```to the generation command.
61+
62+
2. **Go Supported Version Change**
63+
64+
Support version Go 1.19~1.24, the lowest supported version becomes Go 1.19.
65+
66+
if Go version is too low, there will be a prompt when compiling:```note: module requires Go 1.19```.
67+
68+
## **Full Change**
69+
### Feature
70+
[[#1719](https://github.com/cloudwego/kitex/pull/1719)] feat: prutal for replacing protoc
71+
72+
[[#1736](https://github.com/cloudwego/kitex/pull/1736)] feat(ttstream): support WithRecvTimeout stream call option
73+
74+
[[#1702](https://github.com/cloudwego/kitex/pull/1702)] feat(gRPC): add grpc client conn dump to help debug the conn and stream status
75+
76+
[[#1723](https://github.com/cloudwego/kitex/pull/1723)] feat(codec/thrift): use fastcodec/frugal if apache codec not available
77+
78+
[[#1724](https://github.com/cloudwego/kitex/pull/1724)] feat: add tail option to support for delayed initialization of some client options
79+
80+
### Optimize
81+
[[#1728](https://github.com/cloudwego/kitex/pull/1728)] optimize(apache): remove apache codec gen and set default protocol from buffered to framed
82+
83+
[[#1732](https://github.com/cloudwego/kitex/pull/1732)] optimize(rpcinfo): purify the transport protocol of rpcinfo in a single rpc request
84+
85+
[[#1711](https://github.com/cloudwego/kitex/pull/1711)] optimize(tool): disable set validate and deep equal code gen to simplify kitex_gen
86+
87+
[[#1717](https://github.com/cloudwego/kitex/pull/1717)] optimize(gRPC): return more detailed error when received invalid http2 frame
88+
89+
### Fix
90+
[[#1734](https://github.com/cloudwego/kitex/pull/1734)] fix(ttstream): adjust stream state transition and remove all SetFinalizer to avoid memory leak
91+
92+
[[#1735](https://github.com/cloudwego/kitex/pull/1735)] fix(generic): support both relative and absolute check for idl includes parse to make it compatible with generation tool
93+
94+
[[#1725](https://github.com/cloudwego/kitex/pull/1725)] fix: code gen import issue for streamx mode, stream call judgement bug and set ttheader streaming as default
95+
96+
[[#1727](https://github.com/cloudwego/kitex/pull/1727)] fix(tool): fix tool UseStdLib remains unexcepted lib issue
97+
98+
### Refactor
99+
[[#1658](https://github.com/cloudwego/kitex/pull/1658)] refactor: streamx api to adapt both grpc and ttheader streaming protocol and provide more user-friendly interface
100+
101+
[[#1729](https://github.com/cloudwego/kitex/pull/1729)] refactor(tool): move pb tpl code to sep pkg
102+
103+
### Chore
104+
[[#1743](https://github.com/cloudwego/kitex/pull/1743)] chore: update dependencies version
105+
106+
[[#1740](https://github.com/cloudwego/kitex/pull/1740)] chore(generic): deprecate NewThriftContentProvider
107+
108+
[[#1741](https://github.com/cloudwego/kitex/pull/1741)] chore(streamx): remove redundant streamx package
109+
110+
[[#1738](https://github.com/cloudwego/kitex/pull/1738)] ci: fix typos & crate-ci/typos
111+
112+
[[#1737](https://github.com/cloudwego/kitex/pull/1737)] chore: update dependency and change go support to 1.19-1.24
113+
114+
[[#1720](https://github.com/cloudwego/kitex/pull/1720)] Revert "fix(ttstream): pingpong method refers to server interface defined in Kitex generation code when streamx is enabled and there are other streaming methods"

content/en/docs/kitex/Tutorials/basic-feature/streamx/Kitex+StreamX+-+Stream+Basic+Programming.md

Lines changed: 36 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ Current support:
1414

1515
- Transport protocol: TTHeader
1616
- IDL Definition Language and Serialization Protocol: Thrift
17-
- **gRPC Streaming** : ~~~~(planned implementation)
17+
- **gRPC Streaming**
1818

19-
- ~~Transport protocol: gRPC~~
20-
- ~~IDL Definition Language and Serialization Protocol: Protobuf Encoding~~
19+
- Transport protocol: gRPC
20+
- IDL Definition Language and Serialization Protocol: Thrift / Protobuf
2121

2222
The protocol selected here only affects code generated from IDL. Regardless of the protocol, the following usage is consistent.
2323

@@ -44,38 +44,42 @@ service TestService {
4444
```
4545

4646
#### Generate code
47+
Please make sure that Kitex Tool has been upgraded to v0.13.0+:
48+
```
49+
go install github.com/cloudwego/kitex/tool/cmd/kitex@latest
50+
```
4751

48-
To maintain compatibility with legacy stream-generated code, Command Line needs to add `the -streamx ` flag.
52+
To maintain compatibility with legacy stream-generated code, Command Line needs to add the `-streamx` flag.
4953

5054
```
51-
kitex -streamx -module <go module> -service P.S.M echo.thrift
55+
kitex -streamx -module <go module> -service service echo.thrift
5256
```
5357

54-
##### Initialization
58+
### Initialization
5559

5660
#### Create Client
5761

5862
```go
5963
import ".../kitex_gen/echo/testservice"
60-
import "github.com/cloudwego/kitex/client/streamxclient"
64+
import "github.com/cloudwego/kitex/client"
6165

6266
cli, err := testservice.NewClient(
6367
"a.b.c",
64-
streamxclient.WithStreamRecvMiddleware(...),
65-
streamxclient.WithStreamSendMiddleware(...),
68+
client.WithStreamRecvMiddleware(...),
69+
client.WithStreamSendMiddleware(...),
6670
)
6771
```
6872

6973
#### Create Server
7074

7175
```go
72-
import ".../kitex_gen/echo/streamserver"
73-
import "github.com/cloudwego/kitex/server/streamxserver"
76+
import ".../kitex_gen/echo/testservice"
77+
import "github.com/cloudwego/kitex/server"
7478

75-
svr := streamserver.NewServer(
79+
svr := testservice.NewServer(
7680
new(serviceImpl),
77-
streamxserver.WithStreamRecvMiddleware(...),
78-
streamxserver.WithStreamSendMiddleware(...),
81+
server.WithStreamRecvMiddleware(...),
82+
server.WithStreamSendMiddleware(...),
7983
)
8084
```
8185

@@ -101,14 +105,14 @@ client.CloseAndRecv(res) === EOF ==> server.Recv(EOF)
101105

102106
#### Client Usage
103107

104-
- [**Must**] : The client must call the CloseAndRecv () or (CloseSend + Recv) method to inform the server that there is no new data to send.
108+
- [**Must**] : The client must call the CloseAndRecv() or (CloseSend + Recv) method to inform the server that there is no new data to send.
105109

106110
```go
107-
ctx, cs, err := cli.ClientStream(ctx)
111+
stream, err := cli.EchoClient(ctx)
108112
for i := 0; i < 3; i++ {
109-
err = cs.Send(ctx, req)
113+
err = stream.Send(stream.Context(), req)
110114
}
111-
res, err = cs.CloseAndRecv(ctx)
115+
res, err = stream.CloseAndRecv(stream.Context())
112116
```
113117

114118
#### Server usage
@@ -117,14 +121,14 @@ res, err = cs.CloseAndRecv(ctx)
117121

118122
```go
119123

120-
func (si *serviceImpl) ClientStream(
121-
ctx context.Context, stream streamx.ClientStreamingServer[Request, Response]
122-
) (res *Response, err error) {
124+
func (si *serviceImpl) EchoClient(
125+
ctx context.Context, stream echo.TestService_EchoClientServer
126+
) (err error) {
123127
for {
124128
req, err := stream.Recv(ctx)
125129
if err == io.EOF {
126130
res := new(Response)
127-
return res, nil
131+
return stream.SendAndClose(ctx, res)
128132
}
129133
if err != nil {
130134
return nil, err
@@ -153,12 +157,12 @@ client.Recv(EOF) <== EOF === server handler return
153157

154158
#### Client Usage
155159

156-
- [**Must**] : The client must check the io. EOF error and end the loop
160+
- [**Must**] : The client must check the io.EOF error and end the loop
157161

158162
```go
159-
ctx, ss, err := cli.ServerStream(ctx, req)
163+
stream, err := cli.EchoServer(ctx, req)
160164
for {
161-
res, err := ss.Recv(ctx)
165+
res, err := stream.Recv(stream.Context())
162166
if errors.Is(err, io.EOF) {
163167
break
164168
}
@@ -168,7 +172,7 @@ for {
168172
#### Server usage
169173

170174
```go
171-
func (si *serviceImpl) ServerStream(ctx context.Context, req *Request, stream streamx.ServerStreamingServer[Response]) error {
175+
func (si *serviceImpl) EchoServer(ctx context.Context, req *echo.Request, stream echo.TestService_EchoServerServer) error {
172176
for i := 0; i < 3; i++ {
173177
err := stream.Send(ctx, resp)
174178
if err != nil {
@@ -204,23 +208,23 @@ client.Recv(EOF) <== EOF === server handler return
204208
#### Client Usage
205209

206210
- [**Must**] : client must call CloseSend after sending
207-
- [**Must**] : client must judge io. EOF and end the loop when Recv
211+
- [**Must**] : client must judge io.EOF and end the loop when Recv
208212

209213
```go
210-
ctx, bs, err := cli.BidiStream(ctx)
214+
stream, err := cli.EchoBidi(ctx)
211215
var wg sync.WaitGroup
212216
wg.Add(2)
213217
go func() {
214218
defer wg.Done()
215219
for i := 0; i < round; i++ {
216-
err := bs.Send(ctx, req)
220+
err := stream.Send(stream.Context(), req)
217221
}
218-
err = bs.CloseSend(ctx)
222+
err = stream.CloseSend(stream.Context())
219223
}()
220224
go func() {
221225
defer wg.Done()
222226
for {
223-
res, err := bs.Recv(ctx)
227+
res, err := stream.Recv(stream.Context())
224228
if errors.Is(err, io.EOF) {
225229
break
226230
}
@@ -234,7 +238,7 @@ wg.Wait()
234238
- [**Must**] : The server must determine io. EOF and end the loop when Recv
235239

236240
```go
237-
func (si *serviceImpl) BidiStream(ctx context.Context, stream streamx.BidiStreamingServer[Request, Response]) error {
241+
func (si *serviceImpl) EchoBidi(ctx context.Context, stream echo.TestService_EchoBidiServer) error {
238242
for {
239243
req, err := stream.Recv(ctx)
240244
if err == io.EOF {

content/en/docs/kitex/Tutorials/basic-feature/streamx/Kitex+StreamX+-+Stream+Error+Handling.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ Unlike RPC, stream errors can occur at any time during stream processing. For e
1919
Server implementation:
2020

2121
```go
22-
func (si *streamingService) ServerStreamWithErr(ctx context.Context, req *Request, stream streamx.ServerStreamingServer[Response]) error {
22+
func (si *streamingService) ServerStreamWithErr(ctx context.Context, req *echo.Request, stream echo.TestService_ServerStreamWithErrServer) error {
2323
// 检查用户账户余额
2424
for isHasBalance (req.UserId) {
2525
stream.Send(ctx, res)
2626
}
2727
// 返回用户余额不足错误
2828
bizErr := kerrors.NewBizStatusErrorWithExtra(
29-
10001, "insufficient user balance", map[string]string{"testKey": "testVal"}
29+
10001, "insufficient user balance", map[string]string{"testKey": "testVal"},
3030
)
3131
return bizErr
3232
}
@@ -35,11 +35,11 @@ func (si *streamingService) ServerStreamWithErr(ctx context.Context, req *Reques
3535
Client implementation:
3636

3737
```go
38-
svrStream, err = streamClient.ServerStreamWithErr(ctx, req)
38+
stream, err = cli.ServerStreamWithErr(ctx, req)
3939

4040
var err error
4141
for {
42-
res, err = stream.Recv(ctx)
42+
res, err = stream.Recv(stream.Context())
4343
if err != nil {
4444
break
4545
}
@@ -52,12 +52,12 @@ if ok {
5252

5353
### Other errors
5454

55-
If the Error returned by the Server is a non-business exception, the framework will be uniformly encapsulated as `(* thrift.ApplicationException) `. At this time, only the error Message can be obtained.
55+
If the Error returned by the Server is a non-business exception, the framework will be uniformly encapsulated as `(*thrift.ApplicationException)`. At this time, only the error Message can be obtained.
5656

5757
Server implementation:
5858

5959
```go
60-
func (si *streamingService) ServerStreamWithErr(ctx context.Context, req *Request, stream streamx.ServerStreamingServer[Response]) error {
60+
func (si *streamingService) ServerStreamWithErr(ctx context.Context, req *echo.Request, stream echo.TestService_ServerStreamWithErrServer) error {
6161
// ...
6262
return errors.New("test error")
6363
}
@@ -66,16 +66,16 @@ func (si *streamingService) ServerStreamWithErr(ctx context.Context, req *Reques
6666
Client implementation:
6767

6868
```go
69-
svrStream, err = streamClient.ServerStreamWithErr(ctx, req)
70-
test.Assert(t, err == nil, err)
69+
stream, err = cli.ServerStreamWithErr(ctx, req)
7170

7271
var err error
7372
for {
74-
res, err = stream.Recv(ctx)
73+
res, err = stream.Recv(stream.Context())
7574
if err != nil {
7675
break
7776
}
7877
}
78+
7979
ex, ok := err.(*thrift.ApplicationException)
8080
if ok {
8181
println(ex.TypeID(), ex.Msg())

0 commit comments

Comments
 (0)