diff options
author | murgatroid99 <mlumish@google.com> | 2015-09-24 11:29:10 -0700 |
---|---|---|
committer | murgatroid99 <mlumish@google.com> | 2015-09-24 11:29:10 -0700 |
commit | 43a147959e3c139bccfa07da726a3423dfaa4a10 (patch) | |
tree | abafb5d687e20365616e8ad7f30df14313f26374 /src/node/examples | |
parent | b58f69d18d243ce0cabcb0e13b894e6a221a3b35 (diff) |
Added test for using gRPC with other async operations
Diffstat (limited to 'src/node/examples')
-rw-r--r-- | src/node/examples/math_server.js | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/node/examples/math_server.js b/src/node/examples/math_server.js index 31892c65df..a4b237aeeb 100644 --- a/src/node/examples/math_server.js +++ b/src/node/examples/math_server.js @@ -106,15 +106,20 @@ function mathDivMany(stream) { stream.end(); }); } -var server = new grpc.Server(); -server.addProtoService(math.Math.service, { - div: mathDiv, - fib: mathFib, - sum: mathSum, - divMany: mathDivMany -}); + +function getMathServer() { + var server = new grpc.Server(); + server.addProtoService(math.Math.service, { + div: mathDiv, + fib: mathFib, + sum: mathSum, + divMany: mathDivMany + }); + return server; +} if (require.main === module) { + var server = getMathServer(); server.bind('0.0.0.0:50051', grpc.ServerCredentials.createInsecure()); server.start(); } @@ -122,4 +127,4 @@ if (require.main === module) { /** * See docs for server */ -module.exports = server; +module.exports = getMathServer; |