]> gerrit.simantics Code Review - simantics/district.git/blob - attempt.js
d41bbc4fae82578fab9f6b2d3406fc24f37c4cc7
[simantics/district.git] / attempt.js
1 var retry = require('retry')
2
3 module.exports = attempt
4
5 function attempt (cb) {
6   // Tuned to spread 3 attempts over about a minute.
7   // See formula at <https://github.com/tim-kos/node-retry>.
8   var operation = retry.operation(this.config.retry)
9
10   var client = this
11   operation.attempt(function (currentAttempt) {
12     client.log.info(
13       'attempt',
14       'registry request try #' + currentAttempt +
15         ' at ' + (new Date()).toLocaleTimeString()
16     )
17
18     cb(operation)
19   })
20 }