@@ -1571,6 +1571,7 @@ __Arguments__
15711571* ` opts ` - Can be either an object with ` times ` and ` interval ` or a number.
15721572 * ` times ` - The number of attempts to make before giving up. The default is ` 5 ` .
15731573 * ` interval ` - The time to wait between retries, in milliseconds. The default is ` 0 ` .
1574+ The interval may also be specified as a function of the retry count.
15741575 * If ` opts ` is a number, the number specifies the number of times to retry, with the default interval of ` 0 ` .
15751576* ` task(callback, results) ` - A function which receives two arguments: (1) a ` callback(err, result) `
15761577 which must be called when finished, passing ` err ` (which can be ` null ` ) and the ` result ` of
@@ -1595,6 +1596,21 @@ async.retry({times: 3, interval: 200}, apiMethod, function(err, result) {
15951596});
15961597```
15971598
1599+ The interval may also be specified as a function of the retry count:
1600+
1601+ ``` js
1602+ // try calling apiMethod 10 times with exponential backoff
1603+ // (i.e. intervals of 100, 200, 400, 800, 1600, ... milliseconds)
1604+ async .retry ({
1605+ times: 10 ,
1606+ interval : function (retryCount ) {
1607+ return 50 * Math .pow (2 , retryCount);
1608+ }
1609+ }, apiMethod, function (err , result ) {
1610+ // do something with the result
1611+ });
1612+ ```
1613+
15981614``` js
15991615// try calling apiMethod the default 5 times no delay between each retry
16001616async .retry (apiMethod, function (err , result ) {
0 commit comments