Skip to content

Commit 5d8f1e7

Browse files
committed
docs(kitex): improve generic streaming documentation with better imports and standardized terms
1 parent b6bec38 commit 5d8f1e7

File tree

2 files changed

+34
-6
lines changed

2 files changed

+34
-6
lines changed

content/en/docs/kitex/Tutorials/advanced-feature/generic-call/generic_streaming.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,17 @@ First of all, please initialize the streaming client. Here is an example of stre
5151

5252
```go
5353
import (
54-
dproto "github.com/cloudwego/dynamicgo/proto"
54+
"context"
55+
56+
"github.com/cloudwego/kitex/client"
57+
"github.com/cloudwego/kitex/client/genericclient"
58+
"github.com/cloudwego/kitex/pkg/generic"
59+
"github.com/cloudwego/kitex/pkg/generic/proto"
60+
"github.com/cloudwego/kitex/pkg/transmeta"
61+
"github.com/cloudwego/kitex/transport"
5562
)
5663

57-
dOpts := dproto.Options{} // you can specify parsing options as you want
64+
dOpts := proto.Options{} // you can specify parsing options as you want
5865
p, err := generic.NewPbFileProviderWithDynamicGo(your_idl, ctx, dOpts)
5966
// create json pb generic
6067
g, err := generic.JSONPbGeneric(p)
@@ -102,6 +109,16 @@ The four methods included in the example IDL correspond to four scenarios:
102109
Here is an example of streaming client initialization.
103110

104111
```go
112+
import (
113+
"context"
114+
115+
"github.com/cloudwego/kitex/client"
116+
"github.com/cloudwego/kitex/client/genericclient"
117+
"github.com/cloudwego/kitex/pkg/generic"
118+
"github.com/cloudwego/kitex/pkg/transmeta"
119+
"github.com/cloudwego/kitex/transport"
120+
)
121+
105122
p, err := generic.NewThriftFileProvider(your_idl_path)
106123
/*
107124
// if you use dynamicgo

content/zh/docs/kitex/Tutorials/advanced-feature/generic-call/generic_streaming.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,25 @@ service StreamingService {
4141

4242
上述 IDL 包含四种方法,分别对应四种场景:
4343

44-
1. 客户端流:客户端发送多条消息,服务端返回一条消息后关闭流。
45-
2. 服务端流:客户端发送一条消息,服务端返回多条消息后关闭流,适合大模型等场景。
46-
3. 双向流:客户端和服务端可独立收发消息,顺序可自定义。
47-
4. 单次调用(非流式)。
44+
1. Client Streaming:客户端发送多条消息,服务端返回一条消息后关闭流。
45+
2. Server Streaming:客户端发送一条消息,服务端返回多条消息后关闭流,适合大模型等场景。
46+
3. Bidirectional Streaming:客户端和服务端可独立收发消息,顺序可自定义。
47+
4. Unary:单次调用(非流式)。
4848

4949
流式客户端初始化示例:
5050

5151
```go
52+
import (
53+
"context"
54+
55+
"github.com/cloudwego/kitex/client"
56+
"github.com/cloudwego/kitex/client/genericclient"
57+
"github.com/cloudwego/kitex/pkg/generic"
58+
"github.com/cloudwego/kitex/pkg/generic/proto"
59+
"github.com/cloudwego/kitex/pkg/transmeta"
60+
"github.com/cloudwego/kitex/transport"
61+
)
62+
5263
ctx := context.Background()
5364

5465
// 初始化泛化客户端

0 commit comments

Comments
 (0)