trooba-retry

1.0.0 • Public • Published

trooba-retry

Generic retry handler for Trooba framework.

Greenkeeper badge codecov Build Status NPM Downloads Known Vulnerabilities

Install

npm install trooba-retry -S

Usage

const Trooba = require('trooba');

const pipe = Trooba
    .use(require('trooba-retry'), {
        retry: 1,            // number of retries for allowed operations
        operations: ['GET'], // compares against request.operation or context.operation
        codes: ['ETIMEDOUT'] // compares against err.code
    })
    .use(require('trooba-http-transport'), {
        hostname: 'https://www.ebay.com',
        connectTimeout: 100
    })
    .build();

const client = pipe.create({
    operation: 'GET'
});

client.request({ foo: 'bar' }, (err, response) => {
    console.log(err, response);
});

Configuration

  • retry specifies the number of retries in case of retriable error
  • operations <array[string]> is a list of operation names that can be retries; it can be set via config
  • codes <array[string|numbers]> is a list of error codes that can be retried provided that operation is also matched
  • forceRetry will direct to always retry no matter of operation or codes, it can be set in the context or request

Package Sidebar

Install

npm i trooba-retry

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

11.6 kB

Total Files

8

Last publish

Collaborators

  • dimichgh