You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@thrift.apache.org by GitBox <gi...@apache.org> on 2021/02/17 20:25:27 UTC

[GitHub] [thrift] yhlee-tw commented on a change in pull request #2315: THRIFT-4914: Make TClient.Call to return the response meta

yhlee-tw commented on a change in pull request #2315:
URL: https://github.com/apache/thrift/pull/2315#discussion_r577919697



##########
File path: compiler/cpp/src/thrift/generate/t_go_generator.cc
##########
@@ -2091,8 +2108,11 @@ void t_go_generator::generate_service_client(t_service* tservice) {
       std::string resultName = tmp("_result");
       std::string resultType = publicize(method + "_result", true);
       f_types_ << indent() << "var " << resultName << " " << resultType << endl;
-      f_types_ << indent() << "if err = p.Client_().Call(ctx, \""
-        << method << "\", &" << argsName << ", &" << resultName << "); err != nil {" << endl;
+      f_types_ << indent() << "var meta thrift.ResponseMeta" << endl;
+      f_types_ << indent() << "meta, err = p.Client_().Call(ctx, \""
+        << method << "\", &" << argsName << ", &" << resultName << ")" << endl;
+      f_types_ << indent() << "p.SetLastResponseMeta_(meta)" << endl;
+      f_types_ << indent() << "if err != nil {" << endl;

Review comment:
       should we use `tmp("_meta")` or something? I'm seeing `meta` redeclaration errors when `meta` is already defined in args, for example:
   https://github.com/apache/storm/blob/v2.2.0/storm-client/src/storm.thrift#L752
   produces the snippet below which throws `meta` redeclared error
   ```go
   // Parameters:
   //  - Key
   //  - Meta
   func (p *NimbusClient) BeginCreateBlob(ctx context.Context, key string, meta *SettableBlobMeta) (r string, err error) {
     var _args293 NimbusBeginCreateBlobArgs
     _args293.Key = key
     _args293.Meta = meta
     var _result294 NimbusBeginCreateBlobResult
     var meta thrift.ResponseMeta
     meta, err = p.Client_().Call(ctx, "beginCreateBlob", &_args293, &_result294)
     p.SetLastResponseMeta_(meta)
     if err != nil {
       return
     }
     switch {
     case _result294.Aze!= nil:
       return r, _result294.Aze
     case _result294.Kae!= nil:
       return r, _result294.Kae
     }
   
     return _result294.GetSuccess(), nil
   }
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org