UNPKG

aws-cdk-lib

Version:

Version 2 of the AWS Cloud Development Kit library

2 lines (1 loc) 775 B
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.calculateRetryPolicy=calculateRetryPolicy;var core_1=()=>{var tmp=require("../../../core");return core_1=()=>tmp,tmp};const DEFAULT_TIMEOUT=core_1().Duration.minutes(30),DEFAULT_INTERVAL=core_1().Duration.seconds(5);function calculateRetryPolicy(scope,props={}){const totalTimeout=props.totalTimeout||DEFAULT_TIMEOUT,interval=props.queryInterval||DEFAULT_INTERVAL,maxAttempts=totalTimeout.toSeconds()/interval.toSeconds();if(Math.round(maxAttempts)!==maxAttempts)throw new(core_1()).ValidationError(`Cannot determine retry count since totalTimeout=${totalTimeout.toSeconds()}s is not integrally dividable by queryInterval=${interval.toSeconds()}s`,scope);return{maxAttempts,interval,backoffRate:1}}