dns-endpoint-pool
Advanced tools
Comparing version 1.1.0 to 1.2.0
@@ -86,2 +86,10 @@ var EndpointPool, | ||
getStatus: function () { | ||
var poolStatus = this.poolManager.getStatus(); | ||
var endpoints = this.poolManager.endpoints; | ||
return _.assign({ | ||
age: Date.now() - this.lastUpdate | ||
}, poolStatus); | ||
}, | ||
stopUpdating: function () { | ||
@@ -88,0 +96,0 @@ clearTimeout(this._updateTimeout); |
{ | ||
"name": "dns-endpoint-pool", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "Manage and load-balance a pool of service endpoints retrieved from a DNS lookup for a service discovery name.", | ||
@@ -17,3 +17,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"underscore": "=1.7.0" | ||
"underscore": "1.8.3" | ||
}, | ||
@@ -20,0 +20,0 @@ "devDependencies": { |
@@ -12,2 +12,3 @@ var _ = require('underscore'); | ||
this.onEndpointRegistered = options.onEndpointRegistered || _.noop; | ||
this.onEndpointSelected = options.onEndpointSelected || _.noop; | ||
} | ||
@@ -27,2 +28,3 @@ | ||
if (this.isInPool(endpoint)) { | ||
this.onEndpointSelected(endpoint); | ||
this._endpointOffset = offset + 1; | ||
@@ -55,2 +57,11 @@ return endpoint; | ||
this.endpoints.push.apply(this.endpoints, newEndpoints); | ||
}, | ||
getStatus: function () { | ||
var manager = this; | ||
return { | ||
total: this.endpoints.length, | ||
unhealthy: this.endpoints.reduce(function (badCount, endpoint) { | ||
return badCount + (manager.isInPool(endpoint) ? 0 : 1); | ||
}, 0) | ||
} | ||
} | ||
@@ -96,4 +107,2 @@ }; | ||
case HALF_OPEN_READY: | ||
endpoint.state = HALF_OPEN_PENDING; // let one through, then turn it off again | ||
/* falls through */ | ||
case CLOSED: | ||
@@ -105,2 +114,7 @@ return true; | ||
}, | ||
onEndpointSelected: function (endpoint) { | ||
if (endpoint.state === HALF_OPEN_READY) { | ||
endpoint.state = HALF_OPEN_PENDING; // let one through, then turn it off again | ||
} | ||
}, | ||
onEndpointRegistered: function (endpoint) { | ||
@@ -107,0 +121,0 @@ endpoint.state = CLOSED; |
@@ -61,2 +61,10 @@ ## DNS Endpoint Pool | ||
### `pool.getStatus()` | ||
Returns an object containing information about the health of the pool. There are three values: | ||
- `total`: The total number of endpoints in the pool, in any status. | ||
- `unhealthy`: The number of endpoints which are unavailable (eg: due to their circuit breaker being open) | ||
- `age`: The number of milliseconds since the last successful update of endpoints. | ||
### `endpoint.url` | ||
@@ -63,0 +71,0 @@ |
@@ -186,2 +186,3 @@ /*globals it, describe, beforeEach, afterEach */ | ||
bazEndpoint, | ||
status, | ||
dep; | ||
@@ -206,2 +207,8 @@ | ||
expect(dep.getEndpoint()).to.be(bazEndpoint); // bar is removed | ||
status = dep.getStatus(); | ||
expect(status.total).to.be(2); | ||
expect(status.unhealthy).to.be(1); | ||
expect(status.age).to.be.a('number'); | ||
dep.stopUpdating(); | ||
@@ -208,0 +215,0 @@ }); |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
24612
8
429
104
2
+ Addedunderscore@1.8.3(transitive)
Updatedunderscore@1.8.3