|
|
|
@ -207,6 +207,25 @@ ClientReadableStream.prototype.getPeer = getPeer; |
|
|
|
|
ClientWritableStream.prototype.getPeer = getPeer; |
|
|
|
|
ClientDuplexStream.prototype.getPeer = getPeer; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Get a call object built with the provided options. Keys for options are |
|
|
|
|
* 'deadline', which takes a date or number, and 'host', which takes a string |
|
|
|
|
* and overrides the hostname to connect to. |
|
|
|
|
* @param {Object} options Options map. |
|
|
|
|
*/ |
|
|
|
|
function getCall(channel, method, options) { |
|
|
|
|
var deadline; |
|
|
|
|
var host; |
|
|
|
|
if (options) { |
|
|
|
|
deadline = options.deadline; |
|
|
|
|
host = options.host; |
|
|
|
|
} |
|
|
|
|
if (deadline === undefined) { |
|
|
|
|
deadline = Infinity; |
|
|
|
|
} |
|
|
|
|
return new grpc.Call(channel, method, deadline, host); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Get a function that can make unary requests to the specified method. |
|
|
|
|
* @param {string} method The name of the method to request |
|
|
|
@ -226,17 +245,13 @@ function makeUnaryRequestFunction(method, serialize, deserialize) { |
|
|
|
|
* response is received |
|
|
|
|
* @param {array=} metadata Array of metadata key/value pairs to add to the |
|
|
|
|
* call |
|
|
|
|
* @param {(number|Date)=} deadline The deadline for processing this request. |
|
|
|
|
* Defaults to infinite future |
|
|
|
|
* @param {Object=} options Options map |
|
|
|
|
* @return {EventEmitter} An event emitter for stream related events |
|
|
|
|
*/ |
|
|
|
|
function makeUnaryRequest(argument, callback, metadata, deadline) { |
|
|
|
|
function makeUnaryRequest(argument, callback, metadata, options) { |
|
|
|
|
/* jshint validthis: true */ |
|
|
|
|
if (deadline === undefined) { |
|
|
|
|
deadline = Infinity; |
|
|
|
|
} |
|
|
|
|
var emitter = new EventEmitter(); |
|
|
|
|
var call = new grpc.Call(this.channel, method, deadline); |
|
|
|
|
var call = getCall(this.channel, method, options); |
|
|
|
|
if (metadata === null || metadata === undefined) { |
|
|
|
|
metadata = {}; |
|
|
|
|
} |
|
|
|
@ -300,16 +315,12 @@ function makeClientStreamRequestFunction(method, serialize, deserialize) { |
|
|
|
|
* response is received |
|
|
|
|
* @param {array=} metadata Array of metadata key/value pairs to add to the |
|
|
|
|
* call |
|
|
|
|
* @param {(number|Date)=} deadline The deadline for processing this request. |
|
|
|
|
* Defaults to infinite future |
|
|
|
|
* @param {Object=} options Options map |
|
|
|
|
* @return {EventEmitter} An event emitter for stream related events |
|
|
|
|
*/ |
|
|
|
|
function makeClientStreamRequest(callback, metadata, deadline) { |
|
|
|
|
function makeClientStreamRequest(callback, metadata, options) { |
|
|
|
|
/* jshint validthis: true */ |
|
|
|
|
if (deadline === undefined) { |
|
|
|
|
deadline = Infinity; |
|
|
|
|
} |
|
|
|
|
var call = new grpc.Call(this.channel, method, deadline); |
|
|
|
|
var call = getCall(this.channel, method, options); |
|
|
|
|
if (metadata === null || metadata === undefined) { |
|
|
|
|
metadata = {}; |
|
|
|
|
} |
|
|
|
@ -374,16 +385,12 @@ function makeServerStreamRequestFunction(method, serialize, deserialize) { |
|
|
|
|
* serialize |
|
|
|
|
* @param {array=} metadata Array of metadata key/value pairs to add to the |
|
|
|
|
* call |
|
|
|
|
* @param {(number|Date)=} deadline The deadline for processing this request. |
|
|
|
|
* Defaults to infinite future |
|
|
|
|
* @param {Object} options Options map |
|
|
|
|
* @return {EventEmitter} An event emitter for stream related events |
|
|
|
|
*/ |
|
|
|
|
function makeServerStreamRequest(argument, metadata, deadline) { |
|
|
|
|
function makeServerStreamRequest(argument, metadata, options) { |
|
|
|
|
/* jshint validthis: true */ |
|
|
|
|
if (deadline === undefined) { |
|
|
|
|
deadline = Infinity; |
|
|
|
|
} |
|
|
|
|
var call = new grpc.Call(this.channel, method, deadline); |
|
|
|
|
var call = getCall(this.channel, method, options); |
|
|
|
|
if (metadata === null || metadata === undefined) { |
|
|
|
|
metadata = {}; |
|
|
|
|
} |
|
|
|
@ -446,16 +453,12 @@ function makeBidiStreamRequestFunction(method, serialize, deserialize) { |
|
|
|
|
* @this {SurfaceClient} Client object. Must have a channel member. |
|
|
|
|
* @param {array=} metadata Array of metadata key/value pairs to add to the |
|
|
|
|
* call |
|
|
|
|
* @param {(number|Date)=} deadline The deadline for processing this request. |
|
|
|
|
* Defaults to infinite future |
|
|
|
|
* @param {Options} options Options map |
|
|
|
|
* @return {EventEmitter} An event emitter for stream related events |
|
|
|
|
*/ |
|
|
|
|
function makeBidiStreamRequest(metadata, deadline) { |
|
|
|
|
function makeBidiStreamRequest(metadata, options) { |
|
|
|
|
/* jshint validthis: true */ |
|
|
|
|
if (deadline === undefined) { |
|
|
|
|
deadline = Infinity; |
|
|
|
|
} |
|
|
|
|
var call = new grpc.Call(this.channel, method, deadline); |
|
|
|
|
var call = getCall(this.channel, method, options); |
|
|
|
|
if (metadata === null || metadata === undefined) { |
|
|
|
|
metadata = {}; |
|
|
|
|
} |
|
|
|
|