UNPKG

@itwin/imodels-client-management

Version:

iModels API client wrapper for applications that manage iModels.

26 lines 1.13 kB
/*--------------------------------------------------------------------------------------------- * Copyright (c) Bentley Systems, Incorporated. All rights reserved. * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ import { isAxiosError } from "axios"; import { Constants } from "../../Constants"; /** Default implementation for {@link HttpRequestRetryPolicy}. */ export class AxiosRetryPolicy { _backoffAlgorithm; constructor(params) { this.maxRetries = params.maxRetries; this._backoffAlgorithm = params.backoffAlgorithm; } maxRetries; shouldRetry(params) { if (isAxiosError(params.error) && params.error.response?.status != null) { return (params.error.response.status >= Constants.httpStatusCodes.internalServerError); } return true; } getSleepDurationInMs(params) { return this._backoffAlgorithm.getSleepDurationInMs(params.retriesInvoked); } } //# sourceMappingURL=AxiosRetryPolicy.js.map