Skip to content

Commit

Permalink
Grafana review fixes (#74)
Browse files Browse the repository at this point in the history
* ci: minor fix

* review fixes
  • Loading branch information
rozetko authored Apr 4, 2023
1 parent c7c255a commit 263b994
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ jobs:
name: ESLint
command: |
yarn install
npm run eslint
npm run lint
test:
<<: *defaults
Expand Down
2 changes: 1 addition & 1 deletion src/datasource/alert_helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function showAlert(error: any) {
message += error;
}

appEvents.emit('alert-error', ["Can't connect to Kentik API", message]);
appEvents.emit('alert-error', ["Kentik API Error", message]);
}

function showCustomAlert(message: string, exceptionData: any, exceptionType: any) {
Expand Down
7 changes: 3 additions & 4 deletions src/datasource/kentik_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,8 @@ export class KentikAPI {
}
}

const retry = (fn: Function, shouldContinue: (error: FetchError) => boolean, retriesLeft = 100, interval = 1000) =>
const retry = (fn: Function, shouldContinue: (error: FetchError) => boolean, retriesLeft = 5, interval = 2000) =>
new Promise((resolve, reject) => {
console.log(`Retries left: ${retriesLeft} - Next retry interval: ${interval}`);
fn()
.then(resolve)
.catch((error: FetchError) => {
Expand All @@ -164,13 +163,13 @@ const retry = (fn: Function, shouldContinue: (error: FetchError) => boolean, ret
return;
}
if (retriesLeft === 0) {
// Maximum retries exceeded
showAlert('Maximum number of retries exceeded, please reload the page');
reject(error);
return;
}
setTimeout(() => {
// Passing on "reject" is the important part
retry(fn, shouldContinue, retriesLeft - 1, interval + 1000).then(resolve, reject);
retry(fn, shouldContinue, retriesLeft - 1, interval * 2).then(resolve, reject);
}, interval);
});
});
Expand Down

0 comments on commit 263b994

Please sign in to comment.