How to use the retry function from async
Find comprehensive JavaScript async.retry code examples handpicked from public code repositorys.
GitHub: raawaa/jav-scrapy
161 162 163 164 165 166 167 168 169 170
// 只在没有指定搜索条件时显示 console.log('获取第%d页中的影片链接 ( %s )...'.green, pageIndex, url); } let retryCount = 1; async.retry(3, function (callback) { let options = program.nomag ? { url: url, headers: { 'Cookie': 'existmag=all' } } : { url: url }; request .get(options, function (err, res, body) {
214
974
47
103 104 105 106 107 108 109 110 111 112
}, // Check MySQL, version function(asyncCallback) { try { var version = '0.0.0'; async.retry({ times: 10, interval: CHECKER_INTERVAL }, function(retryCallback) { console.log('Try to check MySQL version...'); var mysqlConfig = { host : userConfig.MYSQL_HOST,
34
185
0
47 48 49 50 51 52 53 54 55
getRequestHash (type, payload) { return `${type}:${JSON.stringify(payload)}` } request (type, payload, _opts = {}, cb) { async.retry(_opts.retry || 1, next => { this._request(type, payload, _opts, next) }, cb) }
13
3
6
5322 5323 5324 5325 5326 5327 5328 5329 5330 5331
* * // The `retry` function can be used as a stand-alone control flow by passing * // a callback, as shown below: * * // try calling apiMethod 3 times * async.retry(3, apiMethod, function(err, result) { * // do something with the result * }); * * // try calling apiMethod 3 times, waiting 200 ms between each retry
0
2
1
+ 9 other calls in file
GitHub: DEVIL-X-0P/DeadShot-API
309 310 311 312 313 314 315 316 317 318
return cb(null, counter.seq); }, ); }; async.retry(0, retriable, callback); }; /** * Utility function to create a record in counter before incrementing
0
0
1
200 201 202 203 204 205 206 207 208 209
}); }; module.exports.retry = function (opts, pf) { return new Promise(function (resolve, reject) { async.retry( opts, function (callback) { pf() .then(function (msg) {
0
0
2
+ 3 other calls in file
async.parallel is the most popular function in async (1226 examples)