requestretry
Advanced tools
Comparing version 1.4.1 to 1.5.0
# Change Log | ||
## [v1.4.1](https://github.com/fgribreau/node-request-retry/tree/v1.4.1) (2015-09-21) | ||
[Full Changelog](https://github.com/fgribreau/node-request-retry/compare/v1.4.0...v1.4.1) | ||
**Merged pull requests:** | ||
- Update dependencies, fixes build status [\#14](https://github.com/FGRibreau/node-request-retry/pull/14) ([fhemberger](https://github.com/fhemberger)) | ||
## [v1.4.0](https://github.com/fgribreau/node-request-retry/tree/v1.4.0) (2015-07-16) | ||
@@ -4,0 +12,0 @@ |
@@ -23,2 +23,3 @@ 'use strict'; | ||
this.retryDelay = retryDelay; | ||
this.attempts = 0; | ||
@@ -46,5 +47,9 @@ /** | ||
this.maxAttempts--; | ||
this.attempts++; | ||
this._req = Request.request(this.options, function (err, response, body) { | ||
if (this.retryStrategy(err, response) && this.maxAttempts >= 0) { | ||
if (response) { | ||
response.attempts = this.attempts; | ||
} | ||
if (this.retryStrategy(err, response) && this.maxAttempts > 0) { | ||
this._timeout = setTimeout(this._tryUntilFail.bind(this), this.retryDelay); | ||
@@ -51,0 +56,0 @@ return; |
{ | ||
"name": "requestretry", | ||
"description": "request-retry wrap nodejs request to retry http(s) requests in case of error", | ||
"version": "1.4.1", | ||
"version": "1.5.0", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Francois-Guillaume Ribreau", |
@@ -9,3 +9,3 @@ # Request-retry [](https://david-dm.org/FGRibreau/node-request-retry) [](https://drone.io/github.com/FGRibreau/node-request-retry/latest) [](https://www.npmjs.com/package/requestretry) | ||
Request-retry is a drop-in replacement for [request](https://github.com/mikeal/request) but adds two new options `maxAttempts` and `retryDelay`. | ||
Request-retry is a drop-in replacement for [request](https://github.com/mikeal/request) but adds two new options `maxAttempts` and `retryDelay`. It also adds one property to the response, `attempts`. | ||
@@ -25,2 +25,5 @@ ```javascript | ||
// this callback will only be called when the request succeeded or after maxAttempts or on error | ||
if (response) { | ||
console.log('The number of request attempts: ' + response.attempts); | ||
} | ||
}); | ||
@@ -67,3 +70,2 @@ ``` | ||
- Tests | ||
- Use an EventEmitter to notify retries | ||
@@ -70,0 +72,0 @@ ## [Changelog](CHANGELOG.md) |
@@ -9,3 +9,3 @@ 'use strict'; | ||
var o = request({ | ||
url: 'http://filltext.com/?rows=1&delay=10', // wait for 4s | ||
url: 'http://filltext.com/?rows=1&delay=10', // wait for 10s | ||
json: true | ||
@@ -12,0 +12,0 @@ }, function (err) { |
Sorry, the diff of this file is not supported yet
21569
18
191
72