mirror of https://github.com/grpc/grpc-node.git
Fix issues with express benchmark and synchronize package.json with template
This commit is contained in:
parent
77318b1121
commit
5280def201
|
@ -92,7 +92,9 @@ function BenchmarkClient(server_targets, channels, histogram_params,
|
||||||
this.client_options = [];
|
this.client_options = [];
|
||||||
|
|
||||||
for (var i = 0; i < channels; i++) {
|
for (var i = 0; i < channels; i++) {
|
||||||
var new_options = _.assign({host: server_targets[i]}, options);
|
var host_port;
|
||||||
|
host_port = server_targets[i % server_targets.length].split(':')
|
||||||
|
var new_options = _.assign({hostname: host_port[0], port: +host_port[1]}, options);
|
||||||
new_options.agent = new protocol.Agent(new_options);
|
new_options.agent = new protocol.Agent(new_options);
|
||||||
this.client_options[i] = new_options;
|
this.client_options[i] = new_options;
|
||||||
}
|
}
|
||||||
|
@ -172,7 +174,7 @@ BenchmarkClient.prototype.startClosedLoop = function(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
startAllClients(_.assign(options, self.client_options),
|
startAllClients(_.map(self.client_options, _.partial(_.assign, options)),
|
||||||
outstanding_rpcs_per_channel, makeCall, self);
|
outstanding_rpcs_per_channel, makeCall, self);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -236,7 +238,7 @@ BenchmarkClient.prototype.startPoisson = function(
|
||||||
|
|
||||||
var averageIntervalMs = (1 / offered_load) * 1000;
|
var averageIntervalMs = (1 / offered_load) * 1000;
|
||||||
|
|
||||||
startAllClients(_.assign(options, self.client_options),
|
startAllClients(_.map(self.client_options, _.partial(_.assign, options)),
|
||||||
outstanding_rpcs_per_channel, function(opts){
|
outstanding_rpcs_per_channel, function(opts){
|
||||||
var p = PoissonProcess.create(averageIntervalMs, function() {
|
var p = PoissonProcess.create(averageIntervalMs, function() {
|
||||||
makeCall(opts, p);
|
makeCall(opts, p);
|
||||||
|
|
|
@ -46,15 +46,17 @@ var EventEmitter = require('events');
|
||||||
var util = require('util');
|
var util = require('util');
|
||||||
|
|
||||||
var express = require('express');
|
var express = require('express');
|
||||||
|
var bodyParser = require('body-parser')
|
||||||
|
|
||||||
function unaryCall(req, res) {
|
function unaryCall(req, res) {
|
||||||
var reqObj = JSON.parse(req.body);
|
var reqObj = req.body;
|
||||||
var payload = {body: '0'.repeat(reqObj.response_size)};
|
var payload = {body: '0'.repeat(reqObj.response_size)};
|
||||||
res.send(JSON.dumps(payload));
|
res.json(payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
function BenchmarkServer(host, port, tls, generic, response_size) {
|
function BenchmarkServer(host, port, tls, generic, response_size) {
|
||||||
var app = express();
|
var app = express();
|
||||||
|
app.use(bodyParser.json())
|
||||||
app.put('/serviceProto.BenchmarkService.service/unaryCall', unaryCall);
|
app.put('/serviceProto.BenchmarkService.service/unaryCall', unaryCall);
|
||||||
this.input_host = host;
|
this.input_host = host;
|
||||||
this.input_port = port;
|
this.input_port = port;
|
||||||
|
@ -78,7 +80,7 @@ util.inherits(BenchmarkServer, EventEmitter);
|
||||||
BenchmarkServer.prototype.start = function() {
|
BenchmarkServer.prototype.start = function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.server.listen(this.input_port, this.input_hostname, function() {
|
this.server.listen(this.input_port, this.input_hostname, function() {
|
||||||
this.last_wall_time = process.hrtime();
|
self.last_wall_time = process.hrtime();
|
||||||
self.emit('started');
|
self.emit('started');
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -140,7 +140,6 @@ module.exports = function WorkerServiceImpl(benchmark_impl, server) {
|
||||||
console.log('ServerConfig %j', request.setup);
|
console.log('ServerConfig %j', request.setup);
|
||||||
server = new BenchmarkServer('[::]', request.setup.port,
|
server = new BenchmarkServer('[::]', request.setup.port,
|
||||||
request.setup.security_params);
|
request.setup.security_params);
|
||||||
server.start();
|
|
||||||
server.on('started', function() {
|
server.on('started', function() {
|
||||||
stats = server.mark();
|
stats = server.mark();
|
||||||
call.write({
|
call.write({
|
||||||
|
@ -148,6 +147,7 @@ module.exports = function WorkerServiceImpl(benchmark_impl, server) {
|
||||||
port: server.getPort()
|
port: server.getPort()
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
server.start();
|
||||||
break;
|
break;
|
||||||
case 'mark':
|
case 'mark':
|
||||||
if (server) {
|
if (server) {
|
||||||
|
|
Loading…
Reference in New Issue