Skip to content
This repository
Browse code

cathing up with origin

  • Loading branch information...
commit 1be129526cd089dfe0b8fa7ca023fc07555b59b1 2 parents 2d5b40c + b04e212
Slobodan Utvic authored March 15, 2012
5  .gitignore
@@ -6,3 +6,8 @@ build
6 6
 binding.node
7 7
 examples/stress-test-client
8 8
 node_modules
  9
+Makefile.gyp
  10
+binding.Makefile
  11
+binding.target.gyp.mk
  12
+gyp-mac-tool
  13
+out/
5  History.md
Source Rendered
... ...
@@ -1,4 +1,9 @@
1 1
 
  2
+2.0.3 / 2012-03-14 
  3
+==================
  4
+
  5
+  * Removed -Wall (libuv unused vars caused the build to fail...)
  6
+
2 7
 2.0.2 / 2012-02-16 
3 8
 ==================
4 9
 
9  Makefile
@@ -3,17 +3,14 @@ TESTS = $(wildcard test/test.*.js)
3 3
 DOX = ./node_modules/.bin/dox
4 4
 JADE = ./node_modules/.bin/jade
5 5
 
6  
-binding.node: build binding.cc
7  
-	node-waf build
8  
-
9  
-build:
10  
-	node-waf configure
  6
+build/Release/binding.node: binding.cc binding.gyp
  7
+	npm install
11 8
 
12 9
 test:
13 10
 	@node test/run $(TESTS)
14 11
 
15 12
 clean:
16  
-	node-waf clean
  13
+	rm -fr build
17 14
 
18 15
 docs:
19 16
 	$(DOX) < lib/index.js > docs/index.json
18  binding.gyp
... ...
@@ -0,0 +1,18 @@
  1
+{
  2
+  'targets': [
  3
+    {
  4
+      'target_name': 'binding',
  5
+      'sources': [ 'binding.cc' ],
  6
+      'libraries': ['-lzmq'],
  7
+      'cflags!': ['-fno-exceptions'],
  8
+      'cflags_cc!': ['-fno-exceptions'],
  9
+      'conditions': [
  10
+        ['OS=="mac"', {
  11
+          'xcode_settings': {
  12
+            'GCC_ENABLE_CPP_EXCEPTIONS': 'YES'
  13
+          }
  14
+        }]
  15
+      ]
  16
+    }
  17
+  ]
  18
+}
50  examples/dealer_router.js
@@ -4,6 +4,7 @@
4 4
  *
5 5
  */
6 6
 
  7
+<<<<<<< HEAD
7 8
 var cluster = require('cluster'),
8 9
     zeromq = require('zmq'),
9 10
     port = 'tcp://127.0.0.1:12345';
@@ -54,4 +55,53 @@ if (cluster.isMaster) {
54 55
         console.log(socket.identity + ': received ' + envelope + ' - ' + data.toString());
55 56
         socket.send([envelope, data * 2]);
56 57
     });
  58
+=======
  59
+var cluster = require('cluster')
  60
+  , zmq = require('../')
  61
+  , port = 'tcp://127.0.0.1:12345';
  62
+
  63
+if (cluster.isMaster) {
  64
+  for (var i = 0; i < 2; i++) cluster.fork();
  65
+
  66
+  cluster.on('death', function(worker) {
  67
+    console.log('worker ' + worker.pid + ' died');
  68
+  });
  69
+
  70
+  //dealer = client
  71
+
  72
+  var socket = zmq.socket('dealer');
  73
+
  74
+  socket.identity = 'client' + process.pid;
  75
+
  76
+  socket.bind(port, function(err) {
  77
+    if (err) throw err;
  78
+    console.log('bound!');
  79
+
  80
+    setInterval(function() {
  81
+      var value = Math.floor(Math.random()*100);
  82
+
  83
+      console.log(socket.identity + ': asking ' + value);
  84
+      socket.send(value);
  85
+    }, 100);
  86
+
  87
+
  88
+    socket.on('message', function(data) {
  89
+      console.log(socket.identity + ': answer data ' + data);
  90
+    });
  91
+  });
  92
+} else {
  93
+  //router = server
  94
+
  95
+  var socket = zmq.socket('router');
  96
+
  97
+  socket.identity = 'server' + process.pid;
  98
+
  99
+  socket.connect(port);
  100
+  console.log('connected!');
  101
+
  102
+  socket.on('message', function(envelope, data) {
  103
+    console.log(socket.identity + ': received ' + envelope + ' - ' + data.toString());
  104
+    socket.send([envelope, data * 2]);
  105
+  });
  106
+>>>>>>> upstream/master
57 107
 }
76  examples/http/app.js
... ...
@@ -0,0 +1,76 @@
  1
+
  2
+var zmq = require('../../')
  3
+  , sock = zmq.socket('dealer')
  4
+  , http = require('http')
  5
+  , Stream = require('stream')
  6
+
  7
+var server = http.createServer(function(req, res){
  8
+  // res.writeHead(200, req.headers);
  9
+  // req.on('data', function(chunk){
  10
+  //   res.write(chunk);
  11
+  // }).on('end', function(){
  12
+  //   res.end();
  13
+  // });
  14
+
  15
+  console.log(req.method, req.url);
  16
+  var body = 'Hello';
  17
+  res.writeHead(200, { 'Content-Length': body.length });
  18
+  res.write(body);
  19
+  res.end();
  20
+});
  21
+
  22
+var socks = {};
  23
+
  24
+sock.on('message', function(envelope, id, type, data){
  25
+  var id = id.toString()
  26
+    , type = type.toString()
  27
+    , req
  28
+    , res;
  29
+
  30
+  console.log('%s %s', id, type);
  31
+
  32
+  switch (type) {
  33
+    case 'request':
  34
+      req = new Stream;
  35
+      res = new Stream;
  36
+      res.socket = req;
  37
+
  38
+      res.writeHead = function(status, headers){
  39
+        var obj = JSON.stringify({ status: status, header: headers });
  40
+        sock.send([envelope, id, 'response', obj]);
  41
+      };
  42
+
  43
+      res.write = function(data){
  44
+        sock.send([envelope, id, 'data', data]);
  45
+      };
  46
+
  47
+      res.end = function(){
  48
+        sock.send([envelope, id, 'end']);
  49
+      };
  50
+
  51
+      socks[id] = req;
  52
+      data = JSON.parse(data.toString());
  53
+      req.url = data.url;
  54
+      req.method = data.method;
  55
+      req.headers = data.header;
  56
+      // console.log('%s : %s "%s"', id, req.method, req.url);
  57
+      server.emit('request', req, res);
  58
+      break;
  59
+    case 'data':
  60
+      // console.log();
  61
+      // console.log('data');
  62
+      // console.log(data.toString());
  63
+      req = socks[id];
  64
+      req.emit('data', data);
  65
+      break;
  66
+    case 'end':
  67
+      // console.log('end');
  68
+      req = socks[id];
  69
+      req.emit('end');
  70
+      delete socks[id];
  71
+      break;
  72
+  }
  73
+});
  74
+
  75
+sock.connect('tcp://127.0.0.1:5001');
  76
+console.log('app connected to :5001');
19  examples/http/broker.js
... ...
@@ -0,0 +1,19 @@
  1
+
  2
+var zmq = require('../../')
  3
+  , router = zmq.socket('router')
  4
+  , dealer = zmq.socket('dealer');
  5
+
  6
+router.on('message', function(envelope, id){
  7
+  var args = Array.apply(null, arguments);
  8
+  dealer.send(args);
  9
+});
  10
+
  11
+dealer.on('message', function(envelope, id){
  12
+  var args = Array.apply(null, arguments);
  13
+  router.send(args);
  14
+});
  15
+
  16
+router.bind('tcp://127.0.0.1:5000');
  17
+dealer.bind('tcp://127.0.0.1:5001');
  18
+console.log('router bound to :5000');
  19
+console.log('dealer bound to :5001');
18  examples/http/node.js
... ...
@@ -0,0 +1,18 @@
  1
+
  2
+var http = require('http');
  3
+
  4
+var server = http.createServer(function(req, res){
  5
+  // res.writeHead(200, req.headers);
  6
+  // req.on('data', function(chunk){
  7
+  //   res.write(chunk);
  8
+  // }).on('end', function(){
  9
+  //   res.end();
  10
+  // });
  11
+
  12
+  var body = 'Hello';
  13
+  res.writeHead(200, { 'Content-Length': body.length });
  14
+  res.write(body);
  15
+  res.end();
  16
+});
  17
+
  18
+server.listen(3001);
56  examples/http/server.js
... ...
@@ -0,0 +1,56 @@
  1
+
  2
+var http = require('http')
  3
+  , zmq = require('../../')
  4
+  , sock = zmq.socket('dealer');
  5
+
  6
+var requests = {};
  7
+
  8
+http.createServer(function(req, res){
  9
+  var id = Date.now() + Math.random();
  10
+  // console.log('%s : %s "%s"', id, req.method, req.url);
  11
+
  12
+  requests[id] = res;
  13
+
  14
+  var obj = {
  15
+    method: req.method,
  16
+    url: req.url,
  17
+    header: req.headers
  18
+  };
  19
+
  20
+  var json = JSON.stringify(obj);
  21
+
  22
+  sock.send([id, 'request', json]);
  23
+
  24
+  req.on('data', function(chunk){
  25
+    sock.send([id, 'data', chunk]);
  26
+  });
  27
+
  28
+  req.on('end', function(){
  29
+    sock.send([id, 'end']);
  30
+  });
  31
+}).listen(3000);
  32
+
  33
+sock.on('message', function(id, type, data){
  34
+  var id = id.toString()
  35
+    , type = type.toString()
  36
+    , res = requests[id];
  37
+
  38
+  switch (type) {
  39
+    case 'response':
  40
+      data = JSON.parse(data);
  41
+      res.writeHead(data.status, data.header);
  42
+      break;
  43
+    case 'data':
  44
+      res.write(data);
  45
+      break;
  46
+    case 'end':
  47
+      res.end();
  48
+      delete requests[id];
  49
+      break;
  50
+  }
  51
+});
  52
+
  53
+sock.connect('tcp://127.0.0.1:5000');
  54
+
  55
+console.log('HTTP server listening on :3000');
  56
+console.log('dealer connected to :5000');
51  examples/pub_sub.js
@@ -4,6 +4,7 @@
4 4
  *
5 5
  */
6 6
 
  7
+<<<<<<< HEAD
7 8
 var cluster = require('cluster'),
8 9
     zeromq = require('zmq'),
9 10
     port = 'tcp://127.0.0.1:12345';
@@ -55,4 +56,54 @@ if (cluster.isMaster) {
55 56
     socket.on('message', function(data) {
56 57
         console.log(socket.identity + ': received data ' + data.toString());
57 58
     });
  59
+=======
  60
+var cluster = require('cluster')
  61
+  , zmq = require('../')
  62
+  , port = 'tcp://127.0.0.1:12345';
  63
+
  64
+if (cluster.isMaster) {
  65
+  for (var i = 0; i < 2; i++) cluster.fork();
  66
+
  67
+  cluster.on('death', function(worker) {
  68
+    console.log('worker ' + worker.pid + ' died');
  69
+  });
  70
+  
  71
+  //publisher = send only
  72
+  
  73
+  var socket = zmq.socket('pub');
  74
+
  75
+  socket.identity = 'publisher' + process.pid;
  76
+  
  77
+  var stocks = ['AAPL', 'GOOG', 'YHOO', 'MSFT', 'INTC'];
  78
+
  79
+  socket.bind(port, function(err) {
  80
+    if (err) throw err;
  81
+    console.log('bound!');
  82
+    
  83
+    setInterval(function() {
  84
+      var symbol = stocks[Math.floor(Math.random()*stocks.length)]
  85
+        , value = Math.random()*1000;
  86
+
  87
+      console.log(socket.identity + ': sent ' + symbol + ' ' + value);
  88
+      socket.send(symbol + ' ' + value);
  89
+    }, 100);
  90
+  });
  91
+} else {
  92
+  //subscriber = receive only
  93
+  
  94
+  var socket = zmq.socket('sub');
  95
+
  96
+  socket.identity = 'subscriber' + process.pid;
  97
+  
  98
+  socket.connect(port);
  99
+  
  100
+  socket.subscribe('AAPL');
  101
+  socket.subscribe('GOOG');
  102
+
  103
+  console.log('connected!');
  104
+
  105
+  socket.on('message', function(data) {
  106
+    console.log(socket.identity + ': received data ' + data.toString());
  107
+  });
  108
+>>>>>>> upstream/master
58 109
 }
44  examples/push_pull.js
@@ -4,6 +4,7 @@
4 4
  *
5 5
  */
6 6
 
  7
+<<<<<<< HEAD
7 8
 var cluster = require('cluster'),
8 9
     zeromq = require('zmq'),
9 10
     port = 'tcp://127.0.0.1:12345';
@@ -48,4 +49,47 @@ if (cluster.isMaster) {
48 49
     socket.on('message', function(data) {
49 50
         console.log(socket.identity + ': received data ' + data.toString());
50 51
     });
  52
+=======
  53
+var cluster = require('cluster')
  54
+  , zmq = require('../')
  55
+  , port = 'tcp://127.0.0.1:12345';
  56
+
  57
+if (cluster.isMaster) {
  58
+  for (var i = 0; i < 2; i++) cluster.fork();
  59
+
  60
+  cluster.on('death', function(worker) {
  61
+    console.log('worker ' + worker.pid + ' died');
  62
+  });
  63
+  
  64
+  //push = upstream
  65
+  
  66
+  var socket = zmq.socket('push');
  67
+
  68
+  socket.identity = 'upstream' + process.pid;
  69
+
  70
+  socket.bind(port, function(err) {
  71
+    if (err) throw err;
  72
+    console.log('bound!');
  73
+
  74
+    setInterval(function() {
  75
+      var date = new Date();
  76
+
  77
+      console.log(socket.identity + ': sending data ' + date.toString());
  78
+      socket.send(date.toString());
  79
+    }, 500);
  80
+  });
  81
+} else {
  82
+  //pull = downstream
  83
+  
  84
+  var socket = zmq.socket('pull');
  85
+
  86
+  socket.identity = 'downstream' + process.pid;
  87
+  
  88
+  socket.connect(port);
  89
+  console.log('connected!');
  90
+
  91
+  socket.on('message', function(data) {
  92
+    console.log(socket.identity + ': received data ' + data.toString());
  93
+  });
  94
+>>>>>>> upstream/master
51 95
 }
49  examples/rep_req.js
@@ -4,6 +4,7 @@
4 4
  *
5 5
  */
6 6
 
  7
+<<<<<<< HEAD
7 8
 var cluster = require('cluster'),
8 9
     zeromq = require('zmq'),
9 10
     port = 'tcp://127.0.0.1:12345';
@@ -53,4 +54,52 @@ if (cluster.isMaster) {
53 54
     socket.on('message', function(data) {
54 55
         console.log(socket.identity + ': answer data ' + data);
55 56
     });
  57
+=======
  58
+var cluster = require('cluster')
  59
+  , zmq = require('../')
  60
+  , port = 'tcp://127.0.0.1:12345';
  61
+
  62
+if (cluster.isMaster) {
  63
+  for (var i = 0; i < 2; i++) cluster.fork();
  64
+
  65
+  cluster.on('death', function(worker) {
  66
+      console.log('worker ' + worker.pid + ' died');
  67
+  });
  68
+  
  69
+  //responseder = server
  70
+  
  71
+  var socket = zmq.socket('rep');
  72
+
  73
+  socket.identity = 'server' + process.pid;
  74
+
  75
+  socket.bind(port, function(err) {
  76
+    if (err) throw err;
  77
+    console.log('bound!');
  78
+
  79
+    socket.on('message', function(data) {
  80
+      console.log(socket.identity + ': received ' + data.toString());
  81
+      socket.send(2 * data);
  82
+    });
  83
+  });
  84
+} else {
  85
+  //requester = client
  86
+  
  87
+  var socket = zmq.socket('req');
  88
+
  89
+  socket.identity = 'client' + process.pid;
  90
+  
  91
+  socket.connect(port);
  92
+  console.log('connected!');
  93
+
  94
+  setInterval(function() {
  95
+    var value = Math.floor(Math.random()*100);
  96
+      
  97
+    socket.send(value);
  98
+    console.log(socket.identity + ': asking ' + value);
  99
+  }, 100);
  100
+
  101
+  socket.on('message', function(data) {
  102
+    console.log(socket.identity + ': answer data ' + data);
  103
+  });
  104
+>>>>>>> upstream/master
56 105
 }
49  examples/router_dealer.js
@@ -4,6 +4,7 @@
4 4
  *
5 5
  */
6 6
 
  7
+<<<<<<< HEAD
7 8
 var cluster = require('cluster'),
8 9
     zeromq = require('zmq'),
9 10
     port = 'tcp://127.0.0.1:12345';
@@ -53,4 +54,52 @@ if (cluster.isMaster) {
53 54
     socket.on('message', function(data) {
54 55
         console.log(socket.identity + ': answer data ' + data);
55 56
     });
  57
+=======
  58
+var cluster = require('cluster')
  59
+  , zeromq = require('../')
  60
+  , port = 'tcp://127.0.0.1:12345';
  61
+
  62
+if (cluster.isMaster) {
  63
+  for (var i = 0; i < 2; i++) cluster.fork();
  64
+
  65
+  cluster.on('death', function(worker) {
  66
+    console.log('worker ' + worker.pid + ' died');
  67
+  });
  68
+
  69
+  //router = server
  70
+
  71
+  var socket = zeromq.socket('router');
  72
+
  73
+  socket.identity = 'server' + process.pid;
  74
+
  75
+  socket.bind(port, function(err) {
  76
+    if (err) throw err;
  77
+    console.log('bound!');
  78
+
  79
+    socket.on('message', function(envelope, data) {
  80
+      console.log(socket.identity + ': received ' + envelope + ' - ' + data.toString());
  81
+      socket.send([envelope, data * 2]);
  82
+    });
  83
+  });
  84
+} else {
  85
+  //dealer = client
  86
+
  87
+  var socket = zeromq.socket('dealer');
  88
+
  89
+  socket.identity = 'client' + process.pid;
  90
+
  91
+  socket.connect(port);
  92
+  console.log('connected!');
  93
+
  94
+  setInterval(function() {
  95
+    var value = Math.floor(Math.random()*100);
  96
+
  97
+    socket.send(value);
  98
+    console.log(socket.identity + ': asking ' + value);
  99
+  }, 100);
  100
+
  101
+  socket.on('message', function(data) {
  102
+    console.log(socket.identity + ': answer data ' + data);
  103
+  });
  104
+>>>>>>> upstream/master
56 105
 }
17  examples/rpc.js
... ...
@@ -0,0 +1,17 @@
  1
+
  2
+/**
  3
+ * One server two clients
  4
+ */
  5
+
  6
+var cluster = require('cluster')
  7
+  , zmq = require('../')
  8
+  , port = 'tcp://127.0.0.1:12345';
  9
+
  10
+if (cluster.isMaster) {
  11
+  for (var i = 0; i < 2; i++) cluster.fork();
  12
+
  13
+  
  14
+} else {
  15
+  var sock = zmq.socket('dealer');
  16
+  sock.connect(port);
  17
+}
2  lib/index.js
@@ -5,7 +5,7 @@
5 5
 
6 6
 var EventEmitter = require('events').EventEmitter
7 7
   , IOWatcher = process.binding('io_watcher').IOWatcher
8  
-  , zmq = require('../binding');
  8
+  , zmq = require('../build/Release/binding');
9 9
 
10 10
 /**
11 11
  * Expose bindings as the module.
2  package.json
... ...
@@ -1,6 +1,6 @@
1 1
 {
2 2
   "name": "zmq",
3  
-  "version": "2.0.2",
  3
+  "version": "2.0.3",
4 4
   "description": "Bindings for node.js to zeromq",
5 5
   "main": "index",
6 6
   "repository": {
1  wscript
@@ -17,7 +17,6 @@ def configure(conf):
17 17
 
18 18
 def build(bld):
19 19
     obj = bld.new_task_gen("cxx", "shlib", "node_addon")
20  
-    obj.cxxflags = ["-Wall", "-Werror"]
21 20
     obj.target = "binding"
22 21
     obj.source = "binding.cc"
23 22
     obj.uselib = "ZMQ UUID"

0 notes on commit 1be1295

Please sign in to comment.
Something went wrong with that request. Please try again.