@itwin/imodels-client-management
Version:
iModels API client wrapper for applications that manage iModels.
30 lines • 1.31 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.AxiosRetryPolicy = void 0;
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
const axios_1 = require("axios");
const Constants_1 = require("../../Constants");
/** Default implementation for {@link HttpRequestRetryPolicy}. */
class AxiosRetryPolicy {
_backoffAlgorithm;
constructor(params) {
this.maxRetries = params.maxRetries;
this._backoffAlgorithm = params.backoffAlgorithm;
}
maxRetries;
shouldRetry(params) {
if ((0, axios_1.isAxiosError)(params.error) && params.error.response?.status != null) {
return (params.error.response.status >=
Constants_1.Constants.httpStatusCodes.internalServerError);
}
return true;
}
getSleepDurationInMs(params) {
return this._backoffAlgorithm.getSleepDurationInMs(params.retriesInvoked);
}
}
exports.AxiosRetryPolicy = AxiosRetryPolicy;
//# sourceMappingURL=AxiosRetryPolicy.js.map