source: trip-planner-front/node_modules/retry/example/dns.js@ 1ad8e64

Last change on this file since 1ad8e64 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 687 bytes
Line 
1var dns = require('dns');
2var retry = require('../lib/retry');
3
4function faultTolerantResolve(address, cb) {
5 var opts = {
6 retries: 2,
7 factor: 2,
8 minTimeout: 1 * 1000,
9 maxTimeout: 2 * 1000,
10 randomize: true
11 };
12 var operation = retry.operation(opts);
13
14 operation.attempt(function(currentAttempt) {
15 dns.resolve(address, function(err, addresses) {
16 if (operation.retry(err)) {
17 return;
18 }
19
20 cb(operation.mainError(), operation.errors(), addresses);
21 });
22 });
23}
24
25faultTolerantResolve('nodejs.org', function(err, errors, addresses) {
26 console.warn('err:');
27 console.log(err);
28
29 console.warn('addresses:');
30 console.log(addresses);
31});
Note: See TracBrowser for help on using the repository browser.