File tree Expand file tree Collapse file tree 1 file changed +24
-3
lines changed
content/zh/docs/kitex/Tutorials/code-gen Expand file tree Collapse file tree 1 file changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -244,11 +244,32 @@ kitex -module xxx xxxd.thrift
244
244
245
245
想重新生成代码,执行 kitex-all.sh 即可。若想手动调整,打开脚本文件直接编辑命令即可
246
246
247
- #### ` -gen-path `
247
+ #### ` -gen-frugal `
248
248
249
- > 目前只在 thrift 场景生效,protobuf 侧待后续完善实现。
249
+ 适用场景:灰度接入 Frugal 验证稳定性,指定部分结构体,将其 FastCodec 桥接为通过 Frugal 编解码
250
250
251
- 默认场景,kitex 会将代码生成在 kitex_gen 目录下,可以通过 -gen-path 进行调整
251
+ 用法:在 IDL 里为结构体添加 (go.codec='frugal') 的 annotation,例如
252
+
253
+ ``` thrift
254
+ struct FrugalStruct{
255
+ 1: required string st
256
+ 2: required bool bl
257
+ }(go.codec='frugal')
258
+ ```
259
+
260
+ 生成代码时添加 -gen-frugal 参数,这些结构体的 FastCodec 函数实现就会变为 Frugal 实现
261
+
262
+ #### ` -frugal_struct `
263
+
264
+ 适用场景:灰度接入 Frugal 验证稳定性,指定部分结构体,将其 FastCodec 桥接为通过 Frugal 编解码
265
+
266
+ 用法:上文的「-gen-frugal」需配合修改 IDL 内容才能指定结构体。本参数提供了直接生成时指定结构体的配置方式。使用 -frugal_struct $structName 来在生成时指定结构体,可以多次追加该参数来指定多个结构体名字,例如:
267
+
268
+ ``` shell
269
+ kitex -frugal_struct FrualStruct -frugal-struct MyStruct xxx.thrift
270
+ ```
271
+
272
+ 当使用 -frugal_struct 指定时,优先级更高,就不再为 -gen-frugal 的注解场景生成 frugal 编解码了
252
273
253
274
#### ` -protobuf-plugin `
254
275
You can’t perform that action at this time.
0 commit comments