Skip to content

Commit

Permalink
Worker get a clean arguments.
Browse files Browse the repository at this point in the history
  • Loading branch information
athoune committed Jan 15, 2012
1 parent 3fc2d9f commit 94abc50
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
6 changes: 3 additions & 3 deletions examples/triangle/front.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ var web = http.createServer(function (req, res) {
cluster.self(), function(err, resp) {
//console.log('async job sent', resp);
});
cluster.on('id:something long:' + job_id, function() {
//console.log('call back', arguments);
res.end('Hello World\n');
cluster.on('id:something long:' + job_id, function(arg) {
res.write(arg[0]);
res.end('\n');
});
});

Expand Down
2 changes: 1 addition & 1 deletion examples/triangle/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ cluster.queues.push('working');

cluster.worker.on('something long', function(args, respond_to, job_id) {
//console.log('worker got some args', args);
cluster.answer(respond_to, 'something long', job_id, ['done'], function(err, resp) {
cluster.answer(respond_to, 'something long', job_id, ['Hello world!'], function(err, resp) {
});
});

Expand Down
5 changes: 4 additions & 1 deletion lib/cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ var Cluster = function(_port, _address) {
if (command[0] == 'info') {
this.encode('redis_version:2.4.5');
} else {
that.emit('id:' + command[0] + ':' + command[1], command);
var cmd = command[0];
var pid = command[1];
var values = command[2];
that.emit('id:' + cmd + ':' + pid, JSON.parse(values));
this.singleline('OK');
}
});
Expand Down

0 comments on commit 94abc50

Please sign in to comment.