1 | # Popsicle Retry
|
2 |
|
3 | [![NPM version][npm-image]][npm-url]
|
4 | [![NPM downloads][downloads-image]][downloads-url]
|
5 | [![Build status][travis-image]][travis-url]
|
6 | [![Test coverage][coveralls-image]][coveralls-url]
|
7 |
|
8 | > Enable request retry for Popsicle.
|
9 |
|
10 | ## Installation
|
11 |
|
12 | ```
|
13 | npm install popsicle-retry --save
|
14 | ```
|
15 |
|
16 | ## Usage
|
17 |
|
18 | ```js
|
19 | import { retry } from "popsicle-retry";
|
20 |
|
21 | const send = retry(transport);
|
22 | const res = await send(req);
|
23 | ```
|
24 |
|
25 | ### Methods
|
26 |
|
27 | - **retry(fn, shouldRetry?)** Wraps a request function with retry support. Accepts a second function that returns a delay, or `-1` (default is `retries()`).
|
28 | - **retryAllowed(error?, request?)** Check if a request should be retried. Defaults to `5xx` and unavailable errors.
|
29 | - **retries(count?, isRetryAllowed?)** An exponential back-off function, defaulting to 3 retries.
|
30 |
|
31 | ## License
|
32 |
|
33 | Apache 2.0
|
34 |
|
35 | [npm-image]: https://img.shields.io/npm/v/popsicle-retry.svg?style=flat
|
36 | [npm-url]: https://npmjs.org/package/popsicle-retry
|
37 | [downloads-image]: https://img.shields.io/npm/dm/popsicle-retry.svg?style=flat
|
38 | [downloads-url]: https://npmjs.org/package/popsicle-retry
|
39 | [travis-image]: https://img.shields.io/travis/serviejs/popsicle-retry.svg?style=flat
|
40 | [travis-url]: https://travis-ci.org/serviejs/popsicle-retry
|
41 | [coveralls-image]: https://img.shields.io/coveralls/serviejs/popsicle-retry.svg?style=flat
|
42 | [coveralls-url]: https://coveralls.io/r/serviejs/popsicle-retry?branch=master
|