Permalink
Browse files

fixed coding style and idiotic merge mess I created

  • Loading branch information...
utvara committed Mar 15, 2012
1 parent 157e420 commit 81fe8020f6fff88394630852b9ba98d1c4705b2f
View
@@ -4,58 +4,6 @@
*
*/
-<<<<<<< HEAD
-var cluster = require('cluster'),
- zeromq = require('zmq'),
- port = 'tcp://127.0.0.1:12345';
-
-if (cluster.isMaster) {
- //Fork servers.
- for (var i = 0; i < 2; i++) {
- cluster.fork();
- }
-
- cluster.on('death', function(worker) {
- console.log('worker ' + worker.pid + ' died');
- });
-
- //dealer = client
-
- var socket = zeromq.socket('dealer');
-
- socket.identity = 'client' + process.pid;
-
- socket.bind(port, function(err) {
- if (err) throw err;
- console.log('bound!');
-
- setInterval(function() {
- var value = Math.floor(Math.random()*100);
-
- console.log(socket.identity + ': asking ' + value);
- socket.send(value);
- }, 100);
-
-
- socket.on('message', function(data) {
- console.log(socket.identity + ': answer data ' + data);
- });
- });
-} else {
- //router = server
-
- var socket = zeromq.socket('router');
-
- socket.identity = 'server' + process.pid;
-
- socket.connect(port);
- console.log('connected!');
-
- socket.on('message', function(envelope, data) {
- console.log(socket.identity + ': received ' + envelope + ' - ' + data.toString());
- socket.send([envelope, data * 2]);
- });
-=======
var cluster = require('cluster')
, zmq = require('../')
, port = 'tcp://127.0.0.1:12345';
@@ -103,5 +51,4 @@ if (cluster.isMaster) {
console.log(socket.identity + ': received ' + envelope + ' - ' + data.toString());
socket.send([envelope, data * 2]);
});
->>>>>>> upstream/master
}
@@ -4,13 +4,12 @@
*
*/
-var cluster = require('cluster'),
- zeromq = require('zmq'),
- frontPort = 'tcp://127.0.0.1:12345',
- backPort = 'tcp://127.0.0.1:12346';
+var zmq = require('../../')
+ , frontPort = 'tcp://127.0.0.1:12345'
+ , backPort = 'tcp://127.0.0.1:12346';
function createClient (port) {
- var socket = zeromq.socket('pub');
+ var socket = zmq.socket('pub');
socket.identity = 'client' + process.pid;
@@ -26,7 +25,7 @@ function createClient (port) {
};
function createWorker (port) {
- var socket = zeromq.socket('sub');
+ var socket = zmq.socket('sub');
socket.identity = 'worker' + process.pid;
@@ -42,8 +41,8 @@ function createWorker (port) {
};
function createForwarderDevice(frontPort, backPort) {
- var frontSocket = zeromq.socket('sub'),
- backSocket = zeromq.socket('pub');
+ var frontSocket = zmq.socket('sub'),
+ backSocket = zmq.socket('pub');
frontSocket.identity = 'sub' + process.pid;
backSocket.identity = 'pub' + process.pid;
View
@@ -4,13 +4,12 @@
*
*/
-var cluster = require('cluster'),
- zeromq = require('zmq'),
- frontPort = 'tcp://127.0.0.1:12345',
- backPort = 'tcp://127.0.0.1:12346';
+var zmq = require('../../')
+ , frontPort = 'tcp://127.0.0.1:12345'
+ , backPort = 'tcp://127.0.0.1:12346';
function createClient (port) {
- var socket = zeromq.socket('req');
+ var socket = zmq.socket('req');
socket.identity = 'client' + process.pid;
@@ -30,7 +29,7 @@ function createClient (port) {
};
function createServer (port) {
- var socket = zeromq.socket('rep');
+ var socket = zmq.socket('rep');
socket.identity = 'server' + process.pid;
@@ -46,8 +45,8 @@ function createServer (port) {
};
function createQueueDevice(frontPort, backPort) {
- var frontSocket = zeromq.socket('router'),
- backSocket = zeromq.socket('dealer');
+ var frontSocket = zmq.socket('router'),
+ backSocket = zmq.socket('dealer');
frontSocket.identity = 'router' + process.pid;
backSocket.identity = 'dealer' + process.pid;
@@ -4,13 +4,12 @@
*
*/
-var cluster = require('cluster'),
- zeromq = require('zmq'),
- frontPort = 'tcp://127.0.0.1:12345',
- backPort = 'tcp://127.0.0.1:12346';
+var zmq = require('../../')
+ , frontPort = 'tcp://127.0.0.1:12345'
+ , backPort = 'tcp://127.0.0.1:12346';
function createClient (port) {
- var socket = zeromq.socket('push');
+ var socket = zmq.socket('push');
socket.identity = 'client' + process.pid;
@@ -26,7 +25,7 @@ function createClient (port) {
};
function createWorker (port) {
- var socket = zeromq.socket('pull');
+ var socket = zmq.socket('pull');
socket.identity = 'worker' + process.pid;
@@ -41,8 +40,8 @@ function createWorker (port) {
};
function createStreamerDevice(frontPort, backPort) {
- var frontSocket = zeromq.socket('pull'),
- backSocket = zeromq.socket('push');
+ var frontSocket = zmq.socket('pull'),
+ backSocket = zmq.socket('push');
frontSocket.identity = 'sub' + process.pid;
backSocket.identity = 'pub' + process.pid;
View
@@ -4,59 +4,6 @@
*
*/
-<<<<<<< HEAD
-var cluster = require('cluster'),
- zeromq = require('zmq'),
- port = 'tcp://127.0.0.1:12345';
-
-if (cluster.isMaster) {
- //Fork subscribers.
- for (var i = 0; i < 2; i++) {
- cluster.fork();
- }
-
- cluster.on('death', function(worker) {
- console.log('worker ' + worker.pid + ' died');
- });
-
- //publisher = send only
-
- var socket = zeromq.socket('pub');
-
- socket.identity = 'publisher' + process.pid;
-
- var stocks = ['AAPL', 'GOOG', 'YHOO', 'MSFT', 'INTC'];
-
- socket.bind(port, function(err) {
- if (err) throw err;
- console.log('bound!');
-
- setInterval(function() {
- var symbol = stocks[Math.floor(Math.random()*stocks.length)],
- value = Math.random()*1000;
-
- console.log(socket.identity + ': sent ' + symbol + ' ' + value);
- socket.send(symbol + ' ' + value);
- }, 100);
- });
-} else {
- //subscriber = receive only
-
- var socket = zeromq.socket('sub');
-
- socket.identity = 'subscriber' + process.pid;
-
- socket.connect(port);
-
- socket.subscribe('AAPL');
- socket.subscribe('GOOG');
-
- console.log('connected!');
-
- socket.on('message', function(data) {
- console.log(socket.identity + ': received data ' + data.toString());
- });
-=======
var cluster = require('cluster')
, zmq = require('../')
, port = 'tcp://127.0.0.1:12345';
@@ -105,5 +52,4 @@ if (cluster.isMaster) {
socket.on('message', function(data) {
console.log(socket.identity + ': received data ' + data.toString());
});
->>>>>>> upstream/master
}
View
@@ -4,52 +4,6 @@
*
*/
-<<<<<<< HEAD
-var cluster = require('cluster'),
- zeromq = require('zmq'),
- port = 'tcp://127.0.0.1:12345';
-
-if (cluster.isMaster) {
- //Fork workers.
- for (var i = 0; i < 2; i++) {
- cluster.fork();
- }
-
- cluster.on('death', function(worker) {
- console.log('worker ' + worker.pid + ' died');
- });
-
- //push = upstream
-
- var socket = zeromq.socket('push');
-
- socket.identity = 'upstream' + process.pid;
-
- socket.bind(port, function(err) {
- if (err) throw err;
- console.log('bound!');
-
- setInterval(function() {
- var date = new Date();
-
- console.log(socket.identity + ': sending data ' + date.toString());
- socket.send(date.toString());
- }, 500);
- });
-} else {
- //pull = downstream
-
- var socket = zeromq.socket('pull');
-
- socket.identity = 'downstream' + process.pid;
-
- socket.connect(port);
- console.log('connected!');
-
- socket.on('message', function(data) {
- console.log(socket.identity + ': received data ' + data.toString());
- });
-=======
var cluster = require('cluster')
, zmq = require('../')
, port = 'tcp://127.0.0.1:12345';
@@ -91,5 +45,4 @@ if (cluster.isMaster) {
socket.on('message', function(data) {
console.log(socket.identity + ': received data ' + data.toString());
});
->>>>>>> upstream/master
}
View
@@ -4,57 +4,6 @@
*
*/
-<<<<<<< HEAD
-var cluster = require('cluster'),
- zeromq = require('zmq'),
- port = 'tcp://127.0.0.1:12345';
-
-if (cluster.isMaster) {
- //Fork clients.
- for (var i = 0; i < 2; i++) {
- cluster.fork();
- }
-
- cluster.on('death', function(worker) {
- console.log('worker ' + worker.pid + ' died');
- });
-
- //responseder = server
-
- var socket = zeromq.socket('rep');
-
- socket.identity = 'server' + process.pid;
-
- socket.bind(port, function(err) {
- if (err) throw err;
- console.log('bound!');
-
- socket.on('message', function(data) {
- console.log(socket.identity + ': received ' + data.toString());
- socket.send(2 * data);
- });
- });
-} else {
- //requester = client
-
- var socket = zeromq.socket('req');
-
- socket.identity = 'client' + process.pid;
-
- socket.connect(port);
- console.log('connected!');
-
- setInterval(function() {
- var value = Math.floor(Math.random()*100);
-
- socket.send(value);
- console.log(socket.identity + ': asking ' + value);
- }, 100);
-
- socket.on('message', function(data) {
- console.log(socket.identity + ': answer data ' + data);
- });
-=======
var cluster = require('cluster')
, zmq = require('../')
, port = 'tcp://127.0.0.1:12345';
@@ -101,5 +50,4 @@ if (cluster.isMaster) {
socket.on('message', function(data) {
console.log(socket.identity + ': answer data ' + data);
});
->>>>>>> upstream/master
}
View
@@ -4,9 +4,9 @@
*
*/
-var cluster = require('cluster'),
- zeromq = require('zmq'),
- port = 'tcp://127.0.0.1:12345';
+var cluster = require('cluster')
+ , zeromq = require('../')
+ , port = 'tcp://127.0.0.1:12345';
if (cluster.isMaster) {
//Fork servers.
Oops, something went wrong.

0 comments on commit 81fe802

Please sign in to comment.