/web-stream

transform objects to http responses with configurable retry strategy

Primary LanguageJavaScriptBSD 2-Clause "Simplified" LicenseBSD-2-Clause

web-stream

Build Status

Transform objects to http responses with configurable retry strategy.

Construct the stream:

 new WebStream([{[maxBackoff,[shouldRetry]]}])

Where maxBackoff is the maximum amount of time to wait between retries (i.e. 3000 is 3 seconds), shouldRetry is a function with three arguments (err, res, body) and returns a boolean truth-y to retry false-y to continue.

Wire it to another stream for input that sends in:

 {
   url : 'http://some/url',
   method : 'GET'
 }

For HTTP methods that make sense you may also send in: 'body' and 'header' attributes in this object.

Which will be passed to request as it's options paramter.

web-stream is compatible with 0.8 node via the readable-stream module.

run the example:

 $ npm install
 $ cd example ; node .

Contributing

Run the tests:

grunt