@itwin/imodels-client-management
Version:
iModels API client wrapper for applications that manage iModels.
20 lines • 865 B
JavaScript
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
/**
* Exponential backoff algorithm for calculating sleep time after a failed HTTP request.
* Default implementation for {@link BackoffAlgorithm}.
*/
export class ExponentialBackoffAlgorithm {
_baseDelayInMs;
_factor;
constructor(params) {
this._baseDelayInMs = params.baseDelayInMs;
this._factor = params.factor;
}
getSleepDurationInMs(attempt) {
return Math.pow(this._factor, attempt) * this._baseDelayInMs;
}
}
//# sourceMappingURL=ExponentialBackoffAlgorithm.js.map