net-retry-connect
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -17,7 +17,9 @@ var net = require('net'); | ||
client.on('error', function(err) { | ||
if(!operation.retry(err)) { | ||
client.on('error', handleError); | ||
function handleError(err) { | ||
if (!operation.retry(err)) { | ||
cb(err, null) | ||
} | ||
}); | ||
} | ||
@@ -27,2 +29,3 @@ operation.attempt(function () { | ||
if(!cbCalled) { | ||
client.removeListener('error', handleError); | ||
cb(null, client); | ||
@@ -29,0 +32,0 @@ cbCalled = true; |
{ | ||
"name": "net-retry-connect", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Attempt to connect to net Sockets using retry patterns", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -16,5 +16,5 @@ # net-retry-connect | ||
```options``` provides this options: | ||
* port: the TCP port | ||
* host: optional, defaults to ```'localhost'``` | ||
* retryOptions, see retry options for [retry.operation](https://github.com/tim-kos/node-retry#retryoperationoptions) | ||
* ```port```: the TCP port | ||
* ```host```: optional, defaults to ```'localhost'``` | ||
* ```retryOptions```, optional, see retry options for [retry.operation](https://github.com/tim-kos/node-retry#retryoperationoptions) | ||
@@ -48,3 +48,5 @@ ```callback``` returns a client object if connection has been successful. Otherwise it returns the error. | ||
```npm install``` | ||
```npm test``` | ||
``` | ||
npm install | ||
npm test | ||
``` |
@@ -30,2 +30,12 @@ var retryConnect = require('../index'); | ||
}); | ||
it('client should have no listeners attached', function(done) { | ||
setTimeout(function () { | ||
createServer(); | ||
}, 3000); | ||
retryConnect.to({port: 3000, host: 'localhost'}, function (error, client) { | ||
assert.equal(client.listeners('error').length, 0); | ||
done(); | ||
}); | ||
}) | ||
}); | ||
@@ -32,0 +42,0 @@ |
6716
81
51