IssueRaiser

[NodeJS] Promises and async/await

It would be nice if there was a `grpc-tools` and/or `grpc_node_plugin` option that would generate client and server code that follows the ES6 Promise and ES7 async/await model. For example, instead of: https://github.com/grpc/grpc/blob/98f8989a6712118549c432c9f91b6a516250014d/examples/node/static_codegen/greeter_client.js#L35-L37 We could write: ``` [err, response] = await client.sayHello(request); ``` Or something similar. On the server side, instead of: https://github.com/grpc/grpc/blob/98f8989a6712118549c432c9f91b6a516250014d/examples/node/static_codegen/greeter_server.js#L27-L31 We could write: ``` async function sayHello(call) { var reply = new messages.HelloReply(); reply.setMessage('Hello ' + call.request.getName()); return [null, reply] } ``` Again, just ideas. This feature would eliminate the need for wrapper code for users wanting to use this pattern. I would love to know if anyone is interested in this feature or planning on adding it. Thanks! (moved from https://github.com/grpc/grpc/issues/12751)

Posted by alexkreidler on Sep 29, 2017, 9:24 PM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.4,500 issues0 comments

github (Sysadmin)

[NodeJS] Promises and async/await

alexkreidlerSep 29, 2017, 9:24 PM

It would be nice if there was a `grpc-tools` and/or `grpc_node_plugin` option that would generate client and server code that follows the ES6 Promise and ES7 async/await model. For example, instead of: https://github.com/grpc/grpc/blob/98f8989a6712118549c432c9f91b6a516250014d/examples/node/static_codegen/greeter_client.js#L35-L37 We could write: ``` [err, response] = await client.sayHello(request); ``` Or something similar. On the server side, instead of: https://github.com/grpc/grpc/blob/98f8989a6712118549c432c9f91b6a516250014d/examples/node/static_codegen/greeter_server.js#L27-L31 We could write: ``` async function sayHello(call) { var reply = new messages.HelloReply(); reply.setMessage('Hello ' + call.request.getName()); return [null, reply] } ``` Again, just ideas. This feature would eliminate the need for wrapper code for users wanting to use this pattern. I would love to know if anyone is interested in this feature or planning on adding it. Thanks! (moved from https://github.com/grpc/grpc/issues/12751)

Comments (0)

No comments yet. Start the discussion.

Comment on this issue