limitd-client
Advanced tools
Comparing version 2.10.3 to 2.11.0
@@ -174,14 +174,15 @@ const url = require('url'); | ||
this.once('connect', done); | ||
const self = this; | ||
this.socket = reconnect({ | ||
initialDelay: 5, | ||
maxDelay: 50 | ||
initialDelay: 200, | ||
maxDelay: 1000 | ||
}, stream => { | ||
this._onNewStream(stream); | ||
}).once('connect', (connection) => { | ||
connection.setKeepAlive(true, 50); | ||
connection.setNoDelay(); | ||
setImmediate(() => { | ||
this.emit('connect'); | ||
done(); | ||
this.socket.once('disconnect', (err) => { | ||
this.emit('disconnect', err); | ||
}); | ||
self.emit('connect'); | ||
}).on('close', (has_error) => { | ||
@@ -218,2 +219,5 @@ this.emit('close', has_error); | ||
LimitdClient.prototype._onNewStream = function (stream) { | ||
stream.setKeepAlive(true, 50); | ||
stream.setNoDelay(); | ||
stream | ||
@@ -220,0 +224,0 @@ .pipe(lps.decode()) |
{ | ||
"name": "limitd-client", | ||
"version": "2.10.3", | ||
"version": "2.11.0", | ||
"description": "limitd client for node.js", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -84,2 +84,14 @@ [![Build Status](https://travis-ci.org/limitd/node-client.svg)](https://travis-ci.org/limitd/node-client) | ||
## Events | ||
- `connect`: emitted when the client connects to the server. | ||
- `disconnect([err])`: emitted when the client disconnects from the server. | ||
- `error`: emitted in case of errors | ||
- `reconnect(n, delay)`: emitted when attempting to restablish the connection. See [reconnect-core](https://www.npmjs.com/package/reconnect-core). | ||
- `trip(err, failures, cooldown)`: emitted when the circuit-breaker mechanism trips. | ||
- `ready`: emitted when the client is ready to send requests. | ||
- `response`: emitted when the client receives a response. Useful for metrics and debug. | ||
Note: Events on the shard client have the same signature but the last parameter is the instance of the client. | ||
## Sharding | ||
@@ -86,0 +98,0 @@ |
@@ -58,3 +58,4 @@ const LimitdClient = require('./client'); | ||
.on('connect', () => this.emit('connect', client)) | ||
.on('reconnect', () => this.emit('reconnect', client)) | ||
.on('disconnect', (err) => this.emit('disconnect', err, client)) | ||
.on('reconnect', (n, delay) => this.emit('reconnect', n, delay, client)) | ||
.on('close', () => this.emit('close', client)) | ||
@@ -61,0 +62,0 @@ .on('ready', () => this.emit('ready', client)) |
@@ -61,3 +61,3 @@ const net = require('net'); | ||
this._server.port = listener.address().port; | ||
done(); | ||
if (done) { done(); } | ||
}); | ||
@@ -64,0 +64,0 @@ }; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
54306
20
1423
135