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

Version Path
immosquare-cleaner-0.1.52 node_modules/retry/example/dns.js
immosquare-cleaner-0.1.51 node_modules/retry/example/dns.js
immosquare-cleaner-0.1.50 node_modules/retry/example/dns.js
immosquare-cleaner-0.1.49 node_modules/retry/example/dns.js
immosquare-cleaner-0.1.48 node_modules/retry/example/dns.js
immosquare-cleaner-0.1.47 node_modules/retry/example/dns.js
immosquare-cleaner-0.1.46 node_modules/retry/example/dns.js
immosquare-cleaner-0.1.45 node_modules/retry/example/dns.js
immosquare-cleaner-0.1.44 node_modules/retry/example/dns.js
immosquare-cleaner-0.1.43 node_modules/retry/example/dns.js
immosquare-cleaner-0.1.42 node_modules/retry/example/dns.js
immosquare-cleaner-0.1.41 node_modules/retry/example/dns.js
immosquare-cleaner-0.1.40 node_modules/retry/example/dns.js
immosquare-cleaner-0.1.39 node_modules/retry/example/dns.js
immosquare-cleaner-0.1.38 node_modules/retry/example/dns.js
optimacms-0.1.61 spec/dummy/node_modules/retry/example/dns.js
immosquare-cleaner-0.1.32 node_modules/retry/example/dns.js
immosquare-cleaner-0.1.31 node_modules/retry/example/dns.js
immosquare-cleaner-0.1.30 node_modules/retry/example/dns.js
immosquare-cleaner-0.1.29 node_modules/retry/example/dns.js