New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

dns-endpoint-pool

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dns-endpoint-pool - npm Package Compare versions

Comparing version 0.0.1 to 0.1.0

23

index.js

@@ -15,10 +15,11 @@ var EndpointPool,

/**
* @param {String} discoveryName The name of the service discovery host
* @param {Number} ttl How long the endpoints are valid for. The service discovery endpoint will be checked on
* this interval.
* @param {Number} maxFailures Number of failures allowed before the endpoint circuit breaker is tripped.
* @param {Number} failureWindow Size of the sliding window of time in which the failures are counted.
* @param {Number} resetTimeout Amount of time before putting the circuit back into half open state.
* @param {String} discoveryName The name of the service discovery host
* @param {Number} ttl How long the endpoints are valid for. The service discovery endpoint will be checked on
* this interval.
* @param {Number} maxFailures Number of failures allowed before the endpoint circuit breaker is tripped.
* @param {Number} failureWindow Size of the sliding window of time in which the failures are counted.
* @param {Number} resetTimeout Amount of time before putting the circuit back into half open state.
* @param {Function} onReady Callback to execute when endpoints have been primed (updated for the first time)
*/
module.exports = EndpointPool = function (discoveryName, ttl, maxFailures, failureWindow, resetTimeout) {
module.exports = EndpointPool = function (discoveryName, ttl, maxFailures, failureWindow, resetTimeout, onReady) {
if (!discoveryName || !ttl || !maxFailures || !resetTimeout) {

@@ -38,3 +39,3 @@ throw new Error('Must supply all arguments');

this.lastUpdate = Date.now();
this.update();
this.update(onReady);
};

@@ -45,3 +46,3 @@

_.extend(EndpointPool.prototype, {
update: function () {
update: function (onDone) {
this.resolve(function (err, endpoints) {

@@ -55,2 +56,6 @@ if (err || !endpoints || !endpoints.length) {

this._updateTimeout = setTimeout(this.update.bind(this), this.ttl);
if (typeof onDone === 'function') {
onDone();
}
}.bind(this));

@@ -57,0 +62,0 @@ },

{
"name": "dns-endpoint-pool",
"version": "0.0.1",
"version": "0.1.0",
"description": "Manage and load-balance a pool of service endpoints retrieved from a DNS lookup for a service discovery name.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -54,2 +54,3 @@ ## DNS Endpoint Pool

tried again.
- `onReady`: callback that will be executed after the list of endpoints is fetched for the first time. This does *not* guarantee that the endpoint list is not empty.

@@ -56,0 +57,0 @@ ### `pool.getEndpoint()`

@@ -42,2 +42,17 @@ /*globals it, describe, beforeEach, afterEach */

it('will execute a callback after the first update', function () {
var resolve = autoRestore(Sinon.stub(DEP.prototype, 'resolve')),
called = false,
dep;
resolve.callsArgWith(0, null, []);
dep = new DEP('foo.localhost', 5000, 2, 10000, 10000, function () {
called = true;
});
expect(called).to.be(true);
dep.stopUpdating();
});
it('will update on a timer', function () {

@@ -44,0 +59,0 @@ var resolve = autoRestore(Sinon.stub(DEP.prototype, 'resolve')),

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc