Sha256: 1ed998627ee1df8b49c48d158a0bda6c582c2f11b364c64b949cc3486a563e62
Contents?: true
Size: 687 Bytes
Versions: 61
Compression:
Stored size: 687 Bytes
Contents
var dns = require('dns'); var retry = require('../lib/retry'); function faultTolerantResolve(address, cb) { var opts = { retries: 2, factor: 2, minTimeout: 1 * 1000, maxTimeout: 2 * 1000, randomize: true }; var operation = retry.operation(opts); operation.attempt(function(currentAttempt) { dns.resolve(address, function(err, addresses) { if (operation.retry(err)) { return; } cb(operation.mainError(), operation.errors(), addresses); }); }); } faultTolerantResolve('nodejs.org', function(err, errors, addresses) { console.warn('err:'); console.log(err); console.warn('addresses:'); console.log(addresses); });
Version data entries
61 entries across 54 versions & 10 rubygems