{"action":"created","issue":{"url":"https://api.github.com/repos/grpc/grpc/issues/16573","repository_url":"https://api.github.com/repos/grpc/grpc","labels_url":"https://api.github.com/repos/grpc/grpc/issues/16573/labels{/name}","comments_url":"https://api.github.com/repos/grpc/grpc/issues/16573/comments","events_url":"https://api.github.com/repos/grpc/grpc/issues/16573/events","html_url":"https://github.com/grpc/grpc/pull/16573","id":357728596,"node_id":"MDExOlB1bGxSZXF1ZXN0MjEzNjc0NDc0","number":16573,"title":"Add template-friendly function in generated C++ WithAsyncMethod classes","user":{"login":"sutambe","id":1181418,"node_id":"MDQ6VXNlcjExODE0MTg=","avatar_url":"https://avatars0.githubusercontent.com/u/1181418?v=4","gravatar_id":"","url":"https://api.github.com/users/sutambe","html_url":"https://github.com/sutambe","followers_url":"https://api.github.com/users/sutambe/followers","following_url":"https://api.github.com/users/sutambe/following{/other_user}","gists_url":"https://api.github.com/users/sutambe/gists{/gist_id}","starred_url":"https://api.github.com/users/sutambe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sutambe/subscriptions","organizations_url":"https://api.github.com/users/sutambe/orgs","repos_url":"https://api.github.com/users/sutambe/repos","events_url":"https://api.github.com/users/sutambe/events{/privacy}","received_events_url":"https://api.github.com/users/sutambe/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-09-06T16:14:53Z","updated_at":"2018-09-10T18:36:28Z","closed_at":null,"author_association":"NONE","pull_request":{"url":"https://api.github.com/repos/grpc/grpc/pulls/16573","html_url":"https://github.com/grpc/grpc/pull/16573","diff_url":"https://github.com/grpc/grpc/pull/16573.diff","patch_url":"https://github.com/grpc/grpc/pull/16573.patch"},"body":"This PR generates one template-friendly function in `WithAsyncMethod_*` class in C++ code generator. The objective is to call the family of `WithAsyncMethod_Foo::RequestFoo` functions without knowing the exact names of the functions. \r\n\r\nFor instance, I would like to allow application frameworks to write code like below to invoke all the nested `WithAsyncMethod_*::Request*` functions belonging to `AsyncService`.\r\n\r\n```cpp\r\nint nested_async_methods() {\r\n  MyGame::Example::MonsterStorage::AsyncService async;\r\n  // Somehow call WithAsyncMethod_Retrieve::RequestRetrieve \r\n  // and WithAsyncMethod_Store::RequestStore.\r\n  call_nested(async);\r\n  return 0;\r\n}\r\n```\r\nSuch generic code is possible if there is a duplicate of `WithAsyncMethod_*::Request*` function with  a generic name---`Request`. See the diffs for `tests/monster_test.grpc.fb.h` [here](https://github.com/google/flatbuffers/pull/4901/files#diff-62b42c0d54d6d3f7044e45159eebcf8b). Here's how generic code might work. There's some additional discussion in [this](https://github.com/google/flatbuffers/pull/4901) PR.\r\n\r\n```cpp\r\ntemplate <class AsyncService>\r\nstruct CallNested {\r\n  static void call(AsyncService &s) {}\r\n};\r\n\r\ntemplate <class Nested, template <class> class WithAsyncMethod>\r\nstruct CallNested<WithAsyncMethod<Nested>> {\r\n  static void call(WithAsyncMethod<Nested> &async) {\r\n    // The next line is the objective. Of course, in real code, it's not all zeros.\r\n    async.Request(0, 0, 0, 0, 0, 0);\r\n    CallNested<Nested>::call(async);\r\n  };\r\n};\r\n\r\ntemplate <class AsyncService>\r\nvoid call_nested(AsyncService &async) {\r\n  CallNested<AsyncService>::call(async);\r\n}\r\n```\r\n\r\nThe current proposal is to call it `Request` to avoid any possibility of collision with a user-defined rpc operation. An alternative is `operator()`.\r\n\r\nThe changes required in C++ code generator are next to trivial."},"comment":{"url":"https://api.github.com/repos/grpc/grpc/issues/comments/420016226","html_url":"https://github.com/grpc/grpc/pull/16573#issuecomment-420016226","issue_url":"https://api.github.com/repos/grpc/grpc/issues/16573","id":420016226,"node_id":"MDEyOklzc3VlQ29tbWVudDQyMDAxNjIyNg==","user":{"login":"sutambe","id":1181418,"node_id":"MDQ6VXNlcjExODE0MTg=","avatar_url":"https://avatars0.githubusercontent.com/u/1181418?v=4","gravatar_id":"","url":"https://api.github.com/users/sutambe","html_url":"https://github.com/sutambe","followers_url":"https://api.github.com/users/sutambe/followers","following_url":"https://api.github.com/users/sutambe/following{/other_user}","gists_url":"https://api.github.com/users/sutambe/gists{/gist_id}","starred_url":"https://api.github.com/users/sutambe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sutambe/subscriptions","organizations_url":"https://api.github.com/users/sutambe/orgs","repos_url":"https://api.github.com/users/sutambe/repos","events_url":"https://api.github.com/users/sutambe/events{/privacy}","received_events_url":"https://api.github.com/users/sutambe/received_events","type":"User","site_admin":false},"created_at":"2018-09-10T18:36:28Z","updated_at":"2018-09-10T18:36:28Z","author_association":"NONE","body":"I apologize for my approach out of the blue @vjpai @markdroth. Can you please guide me what needs to happen in this PR to get more attention? I'm reaching out to you because I see multiple commits from you to this repo. "}}
{"actor":{"display_login":"sutambe"}}