File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -4,10 +4,11 @@ import * as sleep from 'sleep-promise';
44export const ATTEMPTS_MAX = 3 ;
55export const DEFAULT_SLEEP_SEC = 1 ;
66export const MAX_SLEEP_SEC = 5 ;
7- type IKubernetesApiFunction = ( ) => Promise < any > ;
8-
9- export async function retryKubernetesApiRequest ( func : IKubernetesApiFunction ) {
7+ type IKubernetesApiFunction < ResponseType > = ( ) => Promise < ResponseType > ;
108
9+ export async function retryKubernetesApiRequest < ResponseType > (
10+ func : IKubernetesApiFunction < ResponseType >
11+ ) : Promise < ResponseType > {
1112 for ( let attempt = 1 ; attempt <= ATTEMPTS_MAX ; attempt ++ ) {
1213 try {
1314 return await func ( ) ;
@@ -29,6 +30,8 @@ export async function retryKubernetesApiRequest(func: IKubernetesApiFunction) {
2930 await sleep ( sleepSeconds * 1000 ) ;
3031 }
3132 }
33+
34+ throw new Error ( 'Could not receive a response from the Kubernetes API' ) ;
3235}
3336
3437export function calculateSleepSeconds ( httpResponse : http . IncomingMessage ) : number {
You can’t perform that action at this time.
0 commit comments