How to use the backoff.FibonacciStrategy function in backoff

To help you get started, we’ve selected a few backoff examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github AVVS / ceph-s3 / lib / client.js View on Github external
return storeFile(file).catch(function uploadToS3Failed(err) {
                // default the current try to 0
                currentTry = currentTry || 0;

                if (currentTry >= maxRetryCount) {
                    return Promise.reject(err);
                }

                debug('error uploading to s3: ', err);

                backoffInstance = backoffInstance || new Backoff(retryOpts);
                return Promise
                    .delay(backoffInstance.next())
                    .then(function () {
                        return uploadFile(file, index, arrLength, ++currentTry, backoffInstance);
                    });
            });
        })
github gardener / dashboard / backend / lib / watches / journals.js View on Github external
loadOpenIssues().then(() => cb(), err => cb(err))
  }

  const call = backoff.call(loadAllOpenIssues, err => {
    if (err) {
      logger.error('failed to fetch journals', err)
    } else {
      logger.info('successfully fetched journals')
    }
  })
  call.retryIf(err => {
    const willRetry = err.status === 503
    logger.info('will retry to fetch journals', willRetry)
    return willRetry
  })
  call.setStrategy(new backoff.FibonacciStrategy({
    initialDelay: 1e3,
    maxDelay: 60e3,
    randomisationFactor: 0
  }))
  call.start()
}

backoff

Fibonacci and exponential backoffs.

MIT
Latest version published 9 years ago

Package Health Score

65 / 100
Full package analysis