diff options
author | murgatroid99 <mlumish@google.com> | 2015-10-09 14:45:55 -0700 |
---|---|---|
committer | murgatroid99 <mlumish@google.com> | 2015-10-09 14:45:55 -0700 |
commit | 5dbbd9178db5a26b9a765534a561cf1e0cba5e94 (patch) | |
tree | c54ec68a553dc11266c3d4cadd5ef84f9c32b082 /src/node/interop | |
parent | be13d818240bd2f37737d8717d4f77a417f44074 (diff) |
Revert "Added interval_us delay in Node interop server"
This reverts commit 83815eab40568e142f05376dae48c2cef41bfefd.
Diffstat (limited to 'src/node/interop')
-rw-r--r-- | src/node/interop/interop_server.js | 47 |
1 files changed, 6 insertions, 41 deletions
diff --git a/src/node/interop/interop_server.js b/src/node/interop/interop_server.js index cc527364b4..5321005c86 100644 --- a/src/node/interop/interop_server.js +++ b/src/node/interop/interop_server.js @@ -35,7 +35,6 @@ var fs = require('fs'); var path = require('path'); -var async = require('async'); var _ = require('lodash'); var grpc = require('..'); var testProto = grpc.load({ @@ -87,22 +86,6 @@ function getEchoTrailer(call) { return response_trailer; } -/** - * @typedef Payload - * @type {object} - * @property {string} payload_type The payload type - * @property {Buffer} body The payload body - */ - -/** - * Get a payload of the specified type and size. If the requested payload is - * COMPRESSABLE, it returns a zero buffer. If the type is UNCOMRESSABLE, it - * returns a slice of pre-loaded uncompressable data. If the type is RANDOM, - * it returns one of the other choices, chosen at random. - * @param {string} payload_type The type of payload to return - * @param {Number} size The size of the payload body - * @return {Payload} The requested payload - */ function getPayload(payload_type, size) { if (payload_type === 'RANDOM') { payload_type = ['COMPRESSABLE', @@ -116,15 +99,6 @@ function getPayload(payload_type, size) { return {type: payload_type, body: body}; } -function respondWithStream(call, request, callback) { - async.eachSeries(request.response_parameters, function(resp_param, callback) { - setTimeout(function() { - call.write({payload: getPayload(request.response_type, resp_param.size)}); - callback(); - }, resp_param.interval_us/1000); - }, callback); -} - /** * Respond to an empty parameter with an empty response. * NOTE: this currently does not work due to issue #137 @@ -188,13 +162,10 @@ function handleStreamingOutput(call) { call.emit('error', status); return; } - respondWithStream(call, req, function(err) { - if (err) { - call.emit(err); - } else { - call.end(getEchoTrailer(call)); - } + _.each(req.response_parameters, function(resp_param) { + call.write({payload: getPayload(req.response_type, resp_param.size)}); }); + call.end(getEchoTrailer(call)); } /** @@ -204,7 +175,6 @@ function handleStreamingOutput(call) { */ function handleFullDuplex(call) { echoHeader(call); - var call_ended; call.on('data', function(value) { if (value.response_status) { var status = value.response_status; @@ -212,17 +182,12 @@ function handleFullDuplex(call) { call.emit('error', status); return; } - call.pause(); - respondWithStream(call, value, function(err) { - call.resume(); - if (call_ended) { - call.end(getEchoTrailer(call)); - } + _.each(value.response_parameters, function(resp_param) { + call.write({payload: getPayload(value.response_type, resp_param.size)}); }); }); call.on('end', function() { - call_ended = true; - + call.end(getEchoTrailer(call)); }); } |