Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
dns-endpoint-pool
Advanced tools
Manage and load-balance a pool of service endpoints retrieved from a DNS lookup for a service discovery name.
Manage and load-balance a pool of service endpoints retrieved from a DNS lookup for a service discovery name.
Given a DNS setup like so:
$ dig +tcp +short SRV my.domain.example.com
0 0 8000 first.example.com.
0 0 8000 second.example.com.
0 0 8000 third.example.com.
This library exposes those service endpoints via an interface which will load balance (using unweighted round-robin only), and apply a circuit breaker to remove failing endpoints from the pool temporarily. Endpoints will be automatically updated on a timer.
var DNSEndpointPool = require('dns-endpoint-pool');
var pool = new DNSEndpointPool('my.domain.example.com', 10000, 5, 10000);
var endpointInfo = pool.getEndpoint();
if (endpointInfo) {
sendRequest('http://' + endpointInfo.url, function (err) {
// let the pool know if the request was successful
endpointInfo.callback(err);
});
}
If the usage of a endpoint is unsuccessful too many times within a window of time, it will be temporarily disabled.
During this time, getEndpoints()
will not return that endpoint. Afterwards, it will be returned to the pool for one
single usage, and removed again. If that usage is successful, it is restored to the pool fully. If it is unsuccessful,
it is disabled once again.
new DNSEndpointPool(serviceDiscoveryName, ttl, maxFailures, failureWindow, resetTimeout)
Creates a new pool object.
serviceDiscoveryName
: the domain name to get endpoint values fromttl
: the time (in ms) that the DNS lookup values are valid for. They will automatically be refreshed on this
interval.maxFailures
: how many failures from a single endpoint before it is removed from the pool.failureWindow
: size of the sliding window of time in which the failures are counted.resetTimeout
: the length of the window in which to record failures. Also the timeout before an endpoint will be
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.pool.getEndpoint()
Returns the next active endpoint
from the pool, or null
if none are available. If none are available, the pool will
emit 'noEndpoints'
.
endpoint.url
The endpoint url (without protocol) from the DNS lookup.
endpoint.callback(err)
A callback which should be executed exactly once for each call to getEndpoint
. If the err
is truthy, this will count
as a failure of the endpoint. If falsey, it marks the endpoint as successful and allows it to remain in the pool.
'updateError'
event. The endpoint pool will continue to
function, using the previously fetched endpoints.getEndpoints()
(because all endpoints are disabled, for example), the
pool will emit 'noEndpoints'
.var pool = new DNSEndpointPool('my.domain.example.com', 10000, 5, 10000, 10000);
pool.on('updateError', function (err) {
log('Could not fetch endpoints');
});
pool.on('noEndpoints', function () {
log('No endpoints available');
})
Photo of a scary pool by perspective23 used under CC license
MIT, SoundCloud.
FAQs
Manage and load-balance a pool of service endpoints retrieved from a DNS lookup for a service discovery name.
The npm package dns-endpoint-pool receives a total of 0 weekly downloads. As such, dns-endpoint-pool popularity was classified as not popular.
We found that dns-endpoint-pool demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.