Request Queue
Extends Superagent by adding the ability to queue up requests and retry failed requests due to timeouts.
Installation
Install from NPM:
npm install superagent-d2l-queue --save
Usage
superagentQueue(options)
const request = ;const superagentQueue = ; // ... request ;
Options (defaults):
All parameters are optional. The backoff parameter does need to include all parameters. Custom parameters will be merged with default parameters.
queue: undefined // use `superagentQueue.makeQueue()`` backoff: initialTimeout: 2000 // Initial retry timeout maxTimeout: undefined // Max retry timeout expFactor: 14 // Exponental backoff factor (1.4 ^ retryCount) retries: 5 // Number of retries, can be null to have infinite retries { // Compute the time between each retry interval. return Math; } // Enable request retry when a request has timed out. retryEnabled: false // Callback function that will be called when a request has timedout and will be retried. This function // will not be called if retry is disabled retryNotifier: undefined
superagentQueue( { queue: superagentQueue.makeQueue() } )
Specify an Array that will be used as a queue to chain multiple Superagent requests. Only one request will execute at a time. This is similar to what can be done with libraries such as Q.
const request = ;const superagentQueue = ; // ... const queue = superagentQueue; const first = request ; const second = request ; const third = request ; // etc...
Contributing
-
Fork the repository. Committing directly against this repository is highly discouraged.
-
Make your modifications in a branch, updating and writing new unit tests as necessary in the
spec
directory.-
Ensure that all tests pass with
npm test
-
Submit a pull request to this repository. Wait for tests to run and someone to chime in.
-
-
Code Style
This repository is configured with EditorConfig and ESLint rules.