tim-kos/node-retry

How to deal with Promise?

adoyle-h opened this issue · 1 comments

Is it possible to deal with Promise?
If yes, could you provide some example cases?
If not, could you support to refactoring the operation.attempt to return a Promise?

function faultTolerantResolve(address, cb) {         // <== What if the faultTolerantResolve returns a Promise?
  var operation = retry.operation();

  operation.attempt(function(currentAttempt) {
    dns.resolve(address, function(err, addresses) {     // <== What if the dns.resolve returns a Promise?
      if (operation.retry(err)) {
        return;
      }

      cb(err ? operation.mainError() : null, addresses);
    });
  });
}

https://github.com/IndigoUnited/node-promise-retry
This library wraps node-retry to support Promise and it works. I think the issue is resolved.