11cb0ef41Sopenharmony_civar dns = require('dns');
21cb0ef41Sopenharmony_civar retry = require('../lib/retry');
31cb0ef41Sopenharmony_ci
41cb0ef41Sopenharmony_cifunction faultTolerantResolve(address, cb) {
51cb0ef41Sopenharmony_ci  var opts = {
61cb0ef41Sopenharmony_ci    retries: 2,
71cb0ef41Sopenharmony_ci    factor: 2,
81cb0ef41Sopenharmony_ci    minTimeout: 1 * 1000,
91cb0ef41Sopenharmony_ci    maxTimeout: 2 * 1000,
101cb0ef41Sopenharmony_ci    randomize: true
111cb0ef41Sopenharmony_ci  };
121cb0ef41Sopenharmony_ci  var operation = retry.operation(opts);
131cb0ef41Sopenharmony_ci
141cb0ef41Sopenharmony_ci  operation.attempt(function(currentAttempt) {
151cb0ef41Sopenharmony_ci    dns.resolve(address, function(err, addresses) {
161cb0ef41Sopenharmony_ci      if (operation.retry(err)) {
171cb0ef41Sopenharmony_ci        return;
181cb0ef41Sopenharmony_ci      }
191cb0ef41Sopenharmony_ci
201cb0ef41Sopenharmony_ci      cb(operation.mainError(), operation.errors(), addresses);
211cb0ef41Sopenharmony_ci    });
221cb0ef41Sopenharmony_ci  });
231cb0ef41Sopenharmony_ci}
241cb0ef41Sopenharmony_ci
251cb0ef41Sopenharmony_cifaultTolerantResolve('nodejs.org', function(err, errors, addresses) {
261cb0ef41Sopenharmony_ci  console.warn('err:');
271cb0ef41Sopenharmony_ci  console.log(err);
281cb0ef41Sopenharmony_ci
291cb0ef41Sopenharmony_ci  console.warn('addresses:');
301cb0ef41Sopenharmony_ci  console.log(addresses);
311cb0ef41Sopenharmony_ci});