-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Closed
Description
Hello,
I would like to know if it'd be possible to be able to update the times
argument of the retry()
from the task
?
For instance, I would like to be able to increase the interval
value as the attempt count increases or trim down the attempt count to 0
when a particular error occurred (in order to avoid unnecessary doomed attempts).
Example:
var opts = {
times: 3,
interval: 500
};
async.retry(opts, function (callback) {
someCall(function(err) {
if (err) {
switch (err.code) {
case 'Code1':
opts.interval += 500; // Increases the interval for next attempt
return callback(err);
case 'Code2':
opts.times = 0; // Avoid other attempts
return callback(err);
default:
return callback(err);
}
}
callback();
});
}, function (err) {
// Some code
});
Any idea or workaround?
Thanks,