mirror of https://github.com/grpc/grpc-node.git
Fixed lint errors
This commit is contained in:
parent
c16a9bdcee
commit
1b56bf8523
|
|
@ -7,7 +7,7 @@
|
|||
"immed": true,
|
||||
"indent": 2,
|
||||
"latedef": "nofunc",
|
||||
"maxlen": 100,
|
||||
"maxlen": 80,
|
||||
"newcap": true,
|
||||
"node": true,
|
||||
"noarg": true,
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
"strict": true,
|
||||
"trailing": true,
|
||||
"undef": true,
|
||||
"unused": true,
|
||||
"unused": "vars",
|
||||
"globals": {
|
||||
/* Mocha-provided globals */
|
||||
"describe": false,
|
||||
|
|
|
|||
|
|
@ -31,9 +31,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
var _ = require('underscore');
|
||||
var ProtoBuf = require('protobufjs');
|
||||
var fs = require('fs');
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
|
||||
var Transform = require('stream').Transform;
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var grpc = require('..');
|
||||
var testProto = grpc.load(__dirname + '/../interop/test.proto').grpc.testing;
|
||||
var _ = require('underscore');
|
||||
|
|
@ -44,7 +46,6 @@ function runTest(iterations, callback) {
|
|||
function runIterations(finish) {
|
||||
var start = process.hrtime();
|
||||
var intervals = [];
|
||||
var pending = iterations;
|
||||
function next(i) {
|
||||
if (i >= iterations) {
|
||||
testServer.server.shutdown();
|
||||
|
|
@ -69,28 +70,30 @@ function runTest(iterations, callback) {
|
|||
|
||||
function warmUp(num) {
|
||||
var pending = num;
|
||||
for (var i = 0; i < num; i++) {
|
||||
(function(i) {
|
||||
function startCall() {
|
||||
client.emptyCall({}, function(err, resp) {
|
||||
pending--;
|
||||
if (pending === 0) {
|
||||
runIterations(callback);
|
||||
}
|
||||
});
|
||||
})(i);
|
||||
}
|
||||
for (var i = 0; i < num; i++) {
|
||||
startCall();
|
||||
}
|
||||
}
|
||||
warmUp(100);
|
||||
}
|
||||
|
||||
function percentile(arr, percentile) {
|
||||
if (percentile > 99) {
|
||||
percentile = 99;
|
||||
function percentile(arr, pct) {
|
||||
if (pct > 99) {
|
||||
pct = 99;
|
||||
}
|
||||
if (percentile < 0) {
|
||||
percentile = 0;
|
||||
if (pct < 0) {
|
||||
pct = 0;
|
||||
}
|
||||
return arr[(arr.length * percentile / 100)|0];
|
||||
var index = Math.floor(arr.length * pct / 100);
|
||||
return arr[index];
|
||||
}
|
||||
|
||||
if (require.main === module) {
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var _ = require('underscore');
|
||||
var grpc = require('..');
|
||||
var examples = grpc.load(__dirname + '/stock.proto').examples;
|
||||
|
|
|
|||
2
index.js
2
index.js
|
|
@ -31,6 +31,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var _ = require('underscore');
|
||||
|
||||
var ProtoBuf = require('protobufjs');
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var grpc = require('..');
|
||||
|
|
@ -41,7 +43,8 @@ var assert = require('assert');
|
|||
|
||||
var AUTH_SCOPE = 'https://www.googleapis.com/auth/xapi.zoo';
|
||||
var AUTH_SCOPE_RESPONSE = 'xapi.zoo';
|
||||
var AUTH_USER = '155450119199-3psnrh1sdr3d8cpj1v46naggf81mhdnk@developer.gserviceaccount.com';
|
||||
var AUTH_USER = ('155450119199-3psnrh1sdr3d8cpj1v46naggf81mhdnk' +
|
||||
'@developer.gserviceaccount.com');
|
||||
|
||||
/**
|
||||
* Create a buffer filled with size zeroes
|
||||
|
|
@ -318,7 +321,7 @@ var test_cases = {
|
|||
/**
|
||||
* Execute a single test case.
|
||||
* @param {string} address The address of the server to connect to, in the
|
||||
* format "hostname:port"
|
||||
* format 'hostname:port'
|
||||
* @param {string} host_overrirde The hostname of the server to use as an SSL
|
||||
* override
|
||||
* @param {string} test_case The name of the test case to run
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var _ = require('underscore');
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
"description": "gRPC Library for Node",
|
||||
"scripts": {
|
||||
"lint": "jshint src test examples interop index.js",
|
||||
"test": "./node_modules/mocha/bin/mocha"
|
||||
"test": "./node_modules/mocha/bin/mocha && npm run-script lint"
|
||||
},
|
||||
"dependencies": {
|
||||
"bindings": "^1.2.1",
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var _ = require('underscore');
|
||||
|
||||
var capitalize = require('underscore.string/capitalize');
|
||||
|
|
@ -77,6 +79,7 @@ function ClientWritableStream(call, serialize) {
|
|||
* @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);
|
||||
this.call.startBatch(batch, function(err, event) {
|
||||
|
|
@ -85,7 +88,7 @@ function _write(chunk, encoding, callback) {
|
|||
}
|
||||
callback();
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
ClientWritableStream.prototype._write = _write;
|
||||
|
||||
|
|
@ -111,6 +114,7 @@ function ClientReadableStream(call, deserialize) {
|
|||
* @param {*} size Ignored because we use objectMode=true
|
||||
*/
|
||||
function _read(size) {
|
||||
/* jshint validthis: true */
|
||||
var self = this;
|
||||
/**
|
||||
* Callback to be called when a READ event is received. Pushes the data onto
|
||||
|
|
@ -126,7 +130,7 @@ function _read(size) {
|
|||
return;
|
||||
}
|
||||
var data = event.read;
|
||||
if (self.push(self.deserialize(data)) && data != null) {
|
||||
if (self.push(self.deserialize(data)) && data !== null) {
|
||||
var read_batch = {};
|
||||
read_batch[grpc.opType.RECV_MESSAGE] = true;
|
||||
self.call.startBatch(read_batch, readCallback);
|
||||
|
|
@ -144,7 +148,7 @@ function _read(size) {
|
|||
self.call.startBatch(read_batch, readCallback);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
ClientReadableStream.prototype._read = _read;
|
||||
|
||||
|
|
@ -163,10 +167,6 @@ function ClientDuplexStream(call, serialize, deserialize) {
|
|||
Duplex.call(this, {objectMode: true});
|
||||
this.serialize = common.wrapIgnoreNull(serialize);
|
||||
this.deserialize = common.wrapIgnoreNull(deserialize);
|
||||
var self = this;
|
||||
var finished = false;
|
||||
// Indicates that a read is currently pending
|
||||
var reading = false;
|
||||
this.call = call;
|
||||
this.on('finish', function() {
|
||||
var batch = {};
|
||||
|
|
@ -182,6 +182,7 @@ ClientDuplexStream.prototype._write = _write;
|
|||
* Cancel the ongoing call
|
||||
*/
|
||||
function cancel() {
|
||||
/* jshint validthis: true */
|
||||
this.call.cancel();
|
||||
}
|
||||
|
||||
|
|
@ -213,6 +214,7 @@ function makeUnaryRequestFunction(method, serialize, deserialize) {
|
|||
* @return {EventEmitter} An event emitter for stream related events
|
||||
*/
|
||||
function makeUnaryRequest(argument, callback, metadata, deadline) {
|
||||
/* jshint validthis: true */
|
||||
if (deadline === undefined) {
|
||||
deadline = Infinity;
|
||||
}
|
||||
|
|
@ -242,7 +244,7 @@ function makeUnaryRequestFunction(method, serialize, deserialize) {
|
|||
callback(err);
|
||||
return;
|
||||
}
|
||||
if (response.status.code != grpc.status.OK) {
|
||||
if (response.status.code !== grpc.status.OK) {
|
||||
callback(response.status);
|
||||
return;
|
||||
}
|
||||
|
|
@ -278,6 +280,7 @@ function makeClientStreamRequestFunction(method, serialize, deserialize) {
|
|||
* @return {EventEmitter} An event emitter for stream related events
|
||||
*/
|
||||
function makeClientStreamRequest(callback, metadata, deadline) {
|
||||
/* jshint validthis: true */
|
||||
if (deadline === undefined) {
|
||||
deadline = Infinity;
|
||||
}
|
||||
|
|
@ -310,7 +313,7 @@ function makeClientStreamRequestFunction(method, serialize, deserialize) {
|
|||
callback(err);
|
||||
return;
|
||||
}
|
||||
if (response.status.code != grpc.status.OK) {
|
||||
if (response.status.code !== grpc.status.OK) {
|
||||
callback(response.status);
|
||||
return;
|
||||
}
|
||||
|
|
@ -345,6 +348,7 @@ function makeServerStreamRequestFunction(method, serialize, deserialize) {
|
|||
* @return {EventEmitter} An event emitter for stream related events
|
||||
*/
|
||||
function makeServerStreamRequest(argument, metadata, deadline) {
|
||||
/* jshint validthis: true */
|
||||
if (deadline === undefined) {
|
||||
deadline = Infinity;
|
||||
}
|
||||
|
|
@ -404,6 +408,7 @@ function makeBidiStreamRequestFunction(method, serialize, deserialize) {
|
|||
* @return {EventEmitter} An event emitter for stream related events
|
||||
*/
|
||||
function makeBidiStreamRequest(metadata, deadline) {
|
||||
/* jshint validthis: true */
|
||||
if (deadline === undefined) {
|
||||
deadline = Infinity;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var _ = require('underscore');
|
||||
|
||||
var capitalize = require('underscore.string/capitalize');
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var _ = require('underscore');
|
||||
|
||||
var capitalize = require('underscore.string/capitalize');
|
||||
|
|
@ -217,6 +219,7 @@ function ServerWritableStream(call, serialize) {
|
|||
* complete
|
||||
*/
|
||||
function _write(chunk, encoding, callback) {
|
||||
/* jshint validthis: true */
|
||||
var batch = {};
|
||||
batch[grpc.opType.SEND_MESSAGE] = this.serialize(chunk);
|
||||
this.call.startBatch(batch, function(err, value) {
|
||||
|
|
@ -251,6 +254,7 @@ function ServerReadableStream(call, deserialize) {
|
|||
* @param {number} size Ignored
|
||||
*/
|
||||
function _read(size) {
|
||||
/* jshint validthis: true */
|
||||
var self = this;
|
||||
/**
|
||||
* Callback to be called when a READ event is received. Pushes the data onto
|
||||
|
|
@ -267,7 +271,7 @@ function _read(size) {
|
|||
return;
|
||||
}
|
||||
var data = event.read;
|
||||
if (self.push(self.deserialize(data)) && data != null) {
|
||||
if (self.push(self.deserialize(data)) && data !== null) {
|
||||
var read_batch = {};
|
||||
read_batch[grpc.opType.RECV_MESSAGE] = true;
|
||||
self.call.startBatch(read_batch, readCallback);
|
||||
|
|
@ -424,7 +428,6 @@ function Server(getMetadata, options) {
|
|||
var handlers = this.handlers;
|
||||
var server = new grpc.Server(options);
|
||||
this._server = server;
|
||||
var started = false;
|
||||
/**
|
||||
* Start the server and begin handling requests
|
||||
* @this Server
|
||||
|
|
@ -456,8 +459,7 @@ function Server(getMetadata, options) {
|
|||
return;
|
||||
}
|
||||
server.requestCall(handleNewCall);
|
||||
var handler = undefined;
|
||||
var deadline = details.deadline;
|
||||
var handler;
|
||||
if (handlers.hasOwnProperty(method)) {
|
||||
handler = handlers[method];
|
||||
} else {
|
||||
|
|
@ -465,7 +467,7 @@ function Server(getMetadata, options) {
|
|||
batch[grpc.opType.SEND_INITIAL_METADATA] = {};
|
||||
batch[grpc.opType.SEND_STATUS_FROM_SERVER] = {
|
||||
code: grpc.status.UNIMPLEMENTED,
|
||||
details: "This method is not available on this server.",
|
||||
details: 'This method is not available on this server.',
|
||||
metadata: {}
|
||||
};
|
||||
batch[grpc.opType.RECV_CLOSE_ON_SERVER] = true;
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var assert = require('assert');
|
||||
var grpc = require('bindings')('grpc.node');
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var assert = require('assert');
|
||||
var grpc = require('bindings')('grpc.node');
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var assert = require('assert');
|
||||
var grpc = require('bindings')('grpc.node');
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var assert = require('assert');
|
||||
var grpc = require('bindings')('grpc.node');
|
||||
|
||||
|
|
@ -227,7 +229,7 @@ describe('end-to-end', function() {
|
|||
response_batch[grpc.opType.RECV_CLOSE_ON_SERVER] = true;
|
||||
server_call.startBatch(response_batch, function(err, response) {
|
||||
assert(response['send status']);
|
||||
assert(!response['cancelled']);
|
||||
assert(!response.cancelled);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var interop_server = require('../interop/interop_server.js');
|
||||
var interop_client = require('../interop/interop_client.js');
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var assert = require('assert');
|
||||
|
||||
var grpc = require('..');
|
||||
|
|
@ -59,7 +61,7 @@ describe('Math client', function() {
|
|||
});
|
||||
it('should handle a single request', function(done) {
|
||||
var arg = {dividend: 7, divisor: 4};
|
||||
var call = math_client.div(arg, function handleDivResult(err, value) {
|
||||
math_client.div(arg, function handleDivResult(err, value) {
|
||||
assert.ifError(err);
|
||||
assert.equal(value.quotient, 1);
|
||||
assert.equal(value.remainder, 3);
|
||||
|
|
|
|||
|
|
@ -31,9 +31,9 @@
|
|||
*
|
||||
*/
|
||||
|
||||
var assert = require('assert');
|
||||
'use strict';
|
||||
|
||||
var surface_server = require('../src/server.js');
|
||||
var assert = require('assert');
|
||||
|
||||
var surface_client = require('../src/client.js');
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue