Skip to content

Commit

Permalink
Merge pull request #70 from djmitche/bug1604649-b
Browse files Browse the repository at this point in the history
Bug 1604649 - actually provide a default for randomizationFactor
  • Loading branch information
djmitche authored Dec 18, 2019
2 parents c482af9 + aa507b2 commit 4aaad94
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/blob.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ function Blob(options) {
agent: agent.globalAgent,
retries: 5,
delayFactor: 100,
randomizationFactor: 0.25,
maxDelay: 30 * 1000,
transientErrorCodes: TRANSIENT_ERROR_CODES,
accountId: undefined,
Expand Down
1 change: 1 addition & 0 deletions lib/queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ function Queue(options) {
agent: agent.globalAgent,
retries: 5,
delayFactor: 100,
randomizationFactor: 0.25,
maxDelay: 30 * 1000,
transientErrorCodes: TRANSIENT_ERROR_CODES,
accountId: undefined,
Expand Down
1 change: 1 addition & 0 deletions lib/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ function Table(options) {
agent: agent.globalAgent,
retries: 5,
delayFactor: 100,
randomizationFactor: 0.25,
maxDelay: 30 * 1000,
transientErrorCodes: TRANSIENT_ERROR_CODES,
accountId: undefined,
Expand Down
4 changes: 3 additions & 1 deletion lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ var retry = function retry(f, options) {
// Compute delay
var delay = Math.pow(2, retry) * options.delayFactor;
var rf = options.randomizationFactor;
delay = delay * (Math.random() * 2 * rf + 1 - rf);
if (rf) {
delay = delay * (Math.random() * 2 * rf + 1 - rf);
}
delay = Math.min(delay, options.maxDelay);

// Sleep for the delay and try again
Expand Down

0 comments on commit 4aaad94

Please sign in to comment.