Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
fantasyni committed Jan 19, 2017
1 parent eea9a4d commit 693f2f4
Show file tree
Hide file tree
Showing 7 changed files with 1,007 additions and 9 deletions.
2 changes: 2 additions & 0 deletions lib/rpc-client/mailboxes/mqtt-mailbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ var utils = require('../../util/utils');
var util = require('util');
var net = require('net');

var CONNECT_TIMEOUT = 2000;

var MailBox = function(server, opts) {
EventEmitter.call(this);
this.curId = 0;
Expand Down
12 changes: 6 additions & 6 deletions sample/bench_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ client.start(function(err) {
run();
});

var num_requests = 20000;
var num_requests = 100000;
var times = 0;
var mock_data_1 = 'hello';
var mock_data_2 = 'hello';
Expand All @@ -60,14 +60,14 @@ for (var i = 0; i < num_repeat; i++) {

var mock_data_3 = {
a: 'run',
b: mock_data_2,
b: mock_data_2 + Date.now() + '_',
time: Date.now()
}

var payload = mock_data_2;
var payload = mock_data_3;

console.log(new Buffer(payload).length / 1024 + 'k');
// console.log(new Buffer(JSON.stringify(payload)).length / 1024 + 'k');
// console.log(new Buffer(payload).length / 1024 + 'k');
console.log(new Buffer(JSON.stringify(payload)).length / 1024 + 'k');

function run() {
if (times > num_requests) {
Expand All @@ -91,7 +91,7 @@ function run() {
}

function rpcRequest(param, cb) {
client.proxies.user.test.service.echo(routeParam, param, function(err, resp) {
client.proxies.user.test.service.echo(routeParam, param, 123, function(err, resp) {
if (err) {
console.error(err.stack);
}
Expand Down
2 changes: 2 additions & 0 deletions sample/bench_server
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
43980
63180
14 changes: 12 additions & 2 deletions sample/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,15 @@ client.start(function(err) {
client.addServers(servers);

var m = new Buffer('hello');
n = 'bbb';
// n = 'bbb';
var fs = require('fs')
// m = fs.readFileSync('./skill.js').toString();
m = [ 'onReloadSkill',
// [ m ],
[ '210108' ],
{ type: 'push', userOptions: {}, isPush: true } ] ;
// m = ['route', [m], {}, {}];
// m = require('./test');
// m = 3.14;
// m = 'aaa';
// m = 100325;
Expand All @@ -43,13 +51,15 @@ client.start(function(err) {
// m = false;
// m = '0';

client.proxies.user.test.service.echo(routeParam, m, function(err, resp) {
client.proxies.user.test.service.echo.toServer('test-server-1', m, 'aaa', function(err, resp, data) {
// client.proxies.user.test.service.echo(routeParam, m, 'aaa', function(err, resp, data) {
if(err) {
console.error(err.stack);
}

// setTimeout(function() {
console.log(resp);
console.log(data);
// console.log(typeof resp)
// console.log(resp.toString())
// }, 1000);
Expand Down
5 changes: 4 additions & 1 deletion sample/remote/test/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

module.exports = function(context) {
return {
echo: function(msg, cb) {
echo: function(msg, data, cb) {
// setTimeout(function() {
// console.log(msg);
// console.log(data);
cb(null, msg);
// cb(null, msg, 'aaa' + Date.now());
// }, 15000);
}
};
Expand Down
Loading

0 comments on commit 693f2f4

Please sign in to comment.