From 3b753db56798913a5b6ade0b04b84bb8a51ec8a3 Mon Sep 17 00:00:00 2001 From: alice <90381261+alice-yyds@users.noreply.github.com> Date: Mon, 23 Dec 2024 13:05:53 +0800 Subject: [PATCH] doc: sync User Guide to Generic Call for Streaming (#1179) Co-authored-by: Marina-Sakai --- .../generic-call/generic_streaming.md | 42 +++++++++++++++---- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/content/en/docs/kitex/Tutorials/advanced-feature/generic-call/generic_streaming.md b/content/en/docs/kitex/Tutorials/advanced-feature/generic-call/generic_streaming.md index 948d34c989..73652156a1 100644 --- a/content/en/docs/kitex/Tutorials/advanced-feature/generic-call/generic_streaming.md +++ b/content/en/docs/kitex/Tutorials/advanced-feature/generic-call/generic_streaming.md @@ -1,18 +1,14 @@ --- -title: "User Guide to Generic Call for Streaming [on trial]" +title: "User Guide to Generic Call for Streaming" date: 2024-09-19 weight: 6 -keywords: ["User Guide to Generic Call for Streaming [on trial]"] +keywords: ["User Guide to Generic Call for Streaming"] description: "" --- ## Introduction -JSON generic call for streaming interfaces is now supported (client-side only). - -**However, due to the ongoing restructuring of the streaming interface to improve the user experience and to avoid making any breaking changes after release, the feature's official release is temporarily on hold. If you have a need for this feature, you can refer to the following to try it out. Please note that once it is officially released, a small adjustment may be required on your end**. - -Please try the feature with kitex test branch test/grpc_json_streaming_generic by `go get github.com/cloudwego/kitex@test/grpc_json_streaming_generic`. +**JSON generic call for streaming interfaces is now supported (client-side only) from Kitex v0.12.0**. ## Usage @@ -54,6 +50,10 @@ The four methods included in the example IDL correspond to four scenarios: First of all, please initialize the streaming client. Here is an example of streaming client initialization. ```go +import ( + dproto "github.com/cloudwego/dynamicgo/proto" +) + dOpts := dproto.Options{} // you can specify parsing options as you want p, err := generic.NewPbFileProviderWithDynamicGo(your_idl, ctx, dOpts) // create json pb generic @@ -102,7 +102,7 @@ The four methods included in the example IDL correspond to four scenarios: Here is an example of streaming client initialization. ```go -p, err := generic.generic.NewThriftFileProvider(your_idl_path) +p, err := generic.NewThriftFileProvider(your_idl_path) /* // if you use dynamicgo p, err := generic.NewThriftFileProviderWithDynamicGo(idl) @@ -225,3 +225,29 @@ Example: resp, err := cli.GenericCall(ctx, "UnaryEcho", `{"message": "unary request"}`) strResp, ok := resp.(string) // response is json string ``` + +## FAQ + +### Recv() got err: rpc error: code = 12 desc = Method not found! + +This error occurs when calling with Kitex **protobuf** generic streaming when the downstream is **gRPC-python** (gRPC libraries for other languages may also have this problem). + +The root cause is that Kitex does not parse the package in the protobuf idl, so the package part of `:path` in the gPRC request is missing, and gRPC-python can't find the corresponding method. + +e.g. + +- normal client + +`:path` - /search.gpt_engine.GPTStreamService/GPTGeneration + +- protobuf generic client + +`:path` - /GPTStreamService/GPTGeneration + +#### Solution + +Use the following branch to solve it and wait for the official release of Kitex v1.18.1 to fix this issue. + +```shell +go get -u github.com/cloudwego/kitex@v0.12.1-0.20241220085925-b5894d2f9e0c +```