Skip to content

Commit

Permalink
Merge pull request #7 from DaMouse404/auto-retry-window
Browse files Browse the repository at this point in the history
Stretch request timeout in line with retry timeout
  • Loading branch information
joshrp committed Aug 14, 2014
2 parents 5a8617d + a167840 commit 5ee9f2f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion lib/Fetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function Fetcher(config) {
api_key: config.apiKey
};
requestOptions = {
timeout: 1000
timeout: 5000
};
retryOptions = {
retries: 3,
Expand Down Expand Up @@ -49,6 +49,7 @@ Fetcher.prototype._request = function (feedName, params) {
var defer = Q.defer(),
that = this,
operation = retry.operation(retryOptions),
timeouts = retry.timeouts(retryOptions),
params = u.extend({}, this.defaultRequestParams, params),
url = this.config.iblUrl + feedName + '.json?' + qs.stringify(params),
requestOptions = u.extend({}, this.requestOptions, {url:url});
Expand All @@ -57,6 +58,8 @@ Fetcher.prototype._request = function (feedName, params) {

if (cached === false) {
operation.attempt(function(currentAttempt) {
requestOptions.timeout = timeouts[currentAttempt-1];

that.request(requestOptions, function (err, response, body) {
if (operation.retry(err)) {
console.log("[INFO] Retrying ", feedName);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fixturator",
"version": "0.1.11",
"version": "0.1.12",
"description": "",
"main": "index.js",
"repository": {
Expand Down

0 comments on commit 5ee9f2f

Please sign in to comment.