Skip to content

Commit

Permalink
Removed spaces and formatted code
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-ext-simba-jy committed Oct 20, 2023
1 parent 11bc6a5 commit 43e8442
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
4 changes: 0 additions & 4 deletions lib/services/sf.js
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,6 @@ function StateAbstract(options)
"CLIENT_APP_VERSION": requestOptions.json.data.CLIENT_APP_VERSION,
"CLIENT_APP_ID": requestOptions.json.data.CLIENT_APP_ID,
})

}

// augment the options with the absolute url
Expand Down Expand Up @@ -1182,7 +1181,6 @@ StateConnecting.prototype.continue = function ()
const maxLoginRetries = connectionConfig.getRetrySfMaxLoginRetries();
let sleep = connectionConfig.getRetrySfStartingSleepTime();
const cap = connectionConfig.getRetrySfMaxSleepTime();
// const isLoginRequest =
Logger.getInstance().debug("Retry Max sleep time = " + cap);
const parent = this;
const requestCallback = function (err, body)
Expand Down Expand Up @@ -1216,9 +1214,7 @@ StateConnecting.prototype.continue = function ()
isRetryableNetworkError(err) || isRetryableHttpError(err)))
{
numRetries++;
// sleep = Util.nextSleepTime(1, cap, sleep);
sleep = Util.jitteredSleepTime(numRetries, sleep, cap);
console.log(sleep);
setTimeout(sendRequest, sleep * 1000);
return;
}
Expand Down
4 changes: 1 addition & 3 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,7 @@ exports.isNode = function ()
/**
* Returns the next sleep time calculated by exponential backoff with
* decorrelated jitter.
* sleep = min(cap, random_between(base, sleep * 3))
*
* sleep = min(cap, random_between(base, sleep * 3))
* for more details, check out:
* http://www.awsarchitectureblog.com/2015/03/backoff.html
* @param base minimum seconds
Expand Down Expand Up @@ -454,7 +453,6 @@ function getJitter (curWaitTime) {
* @param {Number} secondNumber
* @returns {Boolean} return one of the argument randomly.
*/

function chooseRandom (firstNumber, secondNumber) {
const random = Math.floor(Math.random() * 1000);
return random % 2 === 0 ? firstNumber : secondNumber;
Expand Down
13 changes: 7 additions & 6 deletions test/unit/util_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ describe('Util', function ()
assert.strictEqual(url, testCase.result);
})
}
})
});

it("Util.isLoginRequest Test", function () {
const baseUrl = 'wwww.test.com';
Expand Down Expand Up @@ -549,14 +549,15 @@ describe('Util', function ()
{
endPoint: '/tokenRequest',
result:false,
}
},
];

for (const {endPoint,result} of testCases)
{
const isLoginRequest = Util.isLoginRequest(baseUrl+endPoint);
assert.strictEqual(isLoginRequest,result);
const isLoginRequest = Util.isLoginRequest(baseUrl + endPoint);
assert.strictEqual(isLoginRequest, result);
}
})
});

it("Util.jitterSleepTime Test", function () {
const maxSleepTime = 16;
Expand All @@ -567,7 +568,7 @@ describe('Util', function ()
const nextSleep = 2 ** numRetries;

assert.ok(result === nextSleep + jitter || result === nextSleep - jitter)
})
});

it('Util.apply()', function ()
{
Expand Down

0 comments on commit 43e8442

Please sign in to comment.