Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

pix

  • Loading branch information...
commit 7c7c0d51fea90e0954f409b02ddde3c10d1fbcfd 1 parent 824f35f
@substack authored
Showing with 38 additions and 16 deletions.
  1. +2 −0  README.markdown
  2. +2 −1  index.js
  3. +1 −1  package.json
  4. +33 −14 test/recon.js
View
2  README.markdown
@@ -11,6 +11,8 @@ Instead of connecting and listening on hosts and ports, you can .connect() and
[![build status](https://secure.travis-ci.org/substack/airport.png)](http://travis-ci.org/substack/airport)
+![airport](http://substack.net/images/airport.png)
+
example
=======
View
3  index.js
@@ -45,7 +45,6 @@ Airport.prototype.connect = function (opts, fn) {
function onget (ps) {
ports.removeListener('down', ondown);
-
var s = pick(ps);
if (res) res.destroy();
@@ -61,7 +60,9 @@ Airport.prototype.connect = function (opts, fn) {
queue.forEach(function (cb) { res(cb) });
queue = [];
}
+ //if (this._ondown) ports.removeListener('down', this._ondown);
ports.on('down', ondown);
+ this._ondown = ondown;
function connector (service, cb) {
var inst = upnode(cons);
View
2  package.json
@@ -27,7 +27,7 @@
"seaport" : "~0.8.0"
},
"devDependencies" : {
- "tap" : "~0.2.6"
+ "tap" : "~0.3.0"
},
"engines" : {
"node" : ">=0.6.0"
View
47 test/recon.js
@@ -20,18 +20,15 @@ function createServer () {
function runProc (fn) {
var ps = fn();
- setTimeout(function () {
- ps.kill();
- setTimeout(function () {
- if (ref.stopped) return;
- ref.stop = runProc(fn).stop;
- }, 1000);
- }, 1500);
var ref = {};
- ref.stop = function () {
+ ref.restart = function (n) {
ref.stopped = true;
- ps.kill();
+ ps.kill('SIGKILL');
+ setTimeout(function () {
+ var ref_ = runProc(fn);
+ ref.restart = ref_.restart;
+ }, n);
};
return ref;
}
@@ -46,6 +43,7 @@ test('reconnection race', function (t) {
var iv = setInterval(function () {
up(function (remote) {
remote.beep(function (s) {
+ console.log(' ' + s);
results.push(s);
});
});
@@ -54,6 +52,7 @@ test('reconnection race', function (t) {
setTimeout(function () {
t.ok(results.length > 10 * 2, 'enough initial events');
clearInterval(iv);
+ console.log('--- mark ---');
up(function (remote) {
remote.beep(function (s) {
@@ -63,12 +62,32 @@ test('reconnection race', function (t) {
});
}, 10 * 1000);
- var server = runProc(createServer);
- var hub = runProc(createHub);
+ var server = runProc(createServer, 1200);
+ var hub = runProc(createHub, 400);
+
+ up(function (remote) {
+ setTimeout(function () {
+ hub.restart(1500)
+ }, 10);
+
+ setTimeout(function () {
+ hub.restart(200);
+ }, 1900);
+
+ setTimeout(function () {
+ server.restart(2500);
+ }, 100);
+
+ setTimeout(function () {
+ server.restart(300);
+ }, 2700);
+
+ setTimeout(function () {
+ server.restart(600);
+ }, 2300);
+ });
+
t.on('end', function () {
- server.stop();
- hub.stop();
- if (up.close) up.close();
setTimeout(process.exit, 1000);
});
});
Please sign in to comment.
Something went wrong with that request. Please try again.