1.0.0 • Published 4 years ago

trooba-retry v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

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 <arraystring> is a list of operation names that can be retries; it can be set via config
  • codes <arraystring|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