trooba-retry
v1.0.0
Published
Trooba retry handler
Downloads
12
Maintainers
Readme
trooba-retry
Generic retry handler for Trooba framework.
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