summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/npm-registry-client/lib/attempt.js
blob: d41bbc4fae82578fab9f6b2d3406fc24f37c4cc7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
var retry = require('retry')

module.exports = attempt

function attempt (cb) {
  // Tuned to spread 3 attempts over about a minute.
  // See formula at <https://github.com/tim-kos/node-retry>.
  var operation = retry.operation(this.config.retry)

  var client = this
  operation.attempt(function (currentAttempt) {
    client.log.info(
      'attempt',
      'registry request try #' + currentAttempt +
        ' at ' + (new Date()).toLocaleTimeString()
    )

    cb(operation)
  })
}