aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/node/src/client.js
diff options
context:
space:
mode:
authorGravatar murgatroid99 <mlumish@google.com>2015-08-21 12:02:15 -0700
committerGravatar murgatroid99 <mlumish@google.com>2015-08-21 12:02:15 -0700
commit1e9dd32803afed8db333a02aeca000c9ededf2cb (patch)
tree715e14106d91f41c7022c8aa7a8fbcb997fbdec9 /src/node/src/client.js
parente13bfc0139b4ddb560ee3a0e085dbf518a5dabe5 (diff)
parent3c807eac69acd711620aaf7ab44fd79ce406b35e (diff)
Merge branch 'master' into node_method_name_conflicts
Diffstat (limited to 'src/node/src/client.js')
-rw-r--r--src/node/src/client.js29
1 files changed, 24 insertions, 5 deletions
diff --git a/src/node/src/client.js b/src/node/src/client.js
index 90791b4e4c..f288104e2b 100644
--- a/src/node/src/client.js
+++ b/src/node/src/client.js
@@ -79,13 +79,19 @@ function ClientWritableStream(call, serialize) {
* implementation of a method needed for implementing stream.Writable.
* @access private
* @param {Buffer} chunk The chunk to write
- * @param {string} encoding Ignored
+ * @param {string} encoding Used to pass write flags
* @param {function(Error=)} callback Called when the write is complete
*/
function _write(chunk, encoding, callback) {
/* jshint validthis: true */
var batch = {};
- batch[grpc.opType.SEND_MESSAGE] = this.serialize(chunk);
+ var message = this.serialize(chunk);
+ if (_.isFinite(encoding)) {
+ /* Attach the encoding if it is a finite number. This is the closest we
+ * can get to checking that it is valid flags */
+ message.grpcWriteFlags = encoding;
+ }
+ batch[grpc.opType.SEND_MESSAGE] = message;
this.call.startBatch(batch, function(err, event) {
if (err) {
// Something has gone wrong. Stop writing by failing to call callback
@@ -216,14 +222,19 @@ ClientDuplexStream.prototype.getPeer = getPeer;
function getCall(channel, method, options) {
var deadline;
var host;
+ var parent;
+ var propagate_flags;
if (options) {
deadline = options.deadline;
host = options.host;
+ parent = _.get(options, 'parent.call');
+ propagate_flags = options.propagate_flags;
}
if (deadline === undefined) {
deadline = Infinity;
}
- return new grpc.Call(channel, method, deadline, host);
+ return new grpc.Call(channel, method, deadline, host,
+ parent, propagate_flags);
}
/**
@@ -268,8 +279,12 @@ function makeUnaryRequestFunction(method, serialize, deserialize) {
return;
}
var client_batch = {};
+ var message = serialize(argument);
+ if (options) {
+ message.grpcWriteFlags = options.flags;
+ }
client_batch[grpc.opType.SEND_INITIAL_METADATA] = metadata;
- client_batch[grpc.opType.SEND_MESSAGE] = serialize(argument);
+ client_batch[grpc.opType.SEND_MESSAGE] = message;
client_batch[grpc.opType.SEND_CLOSE_FROM_CLIENT] = true;
client_batch[grpc.opType.RECV_INITIAL_METADATA] = true;
client_batch[grpc.opType.RECV_MESSAGE] = true;
@@ -402,9 +417,13 @@ function makeServerStreamRequestFunction(method, serialize, deserialize) {
return;
}
var start_batch = {};
+ var message = serialize(argument);
+ if (options) {
+ message.grpcWriteFlags = options.flags;
+ }
start_batch[grpc.opType.SEND_INITIAL_METADATA] = metadata;
start_batch[grpc.opType.RECV_INITIAL_METADATA] = true;
- start_batch[grpc.opType.SEND_MESSAGE] = serialize(argument);
+ start_batch[grpc.opType.SEND_MESSAGE] = message;
start_batch[grpc.opType.SEND_CLOSE_FROM_CLIENT] = true;
call.startBatch(start_batch, function(err, response) {
if (err) {