Skip to content

Commit

Permalink
fix: always exec checks
Browse files Browse the repository at this point in the history
  • Loading branch information
arnediekmann committed May 16, 2024
1 parent 102bbb6 commit 0501a02
Showing 1 changed file with 18 additions and 20 deletions.
38 changes: 18 additions & 20 deletions src/probes.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,27 @@ export class ProbesService {
) {}

public async checkProbe(probeName: ProbeType): Promise<boolean> {
if (this.statusMap[probeName] === undefined) {
const check = this.options.checks[probeName];

if (check !== undefined) {
let newStatus: boolean;

if (typeof check === 'function') {
const result = await check();

if (typeof result === 'object') {
newStatus = this.checkTerminusHealthResults([result]);
} else if (typeof result === 'boolean') {
newStatus = result;
}
} else {
const results = await Promise.all(check.map(async (f) => await f()));
newStatus = this.checkTerminusHealthResults(results);
}
const check = this.options.checks[probeName];

if (check !== undefined) {
let newStatus: boolean;

if (typeof check === 'function') {
const result = await check();

this.statusMap[probeName] = newStatus;
if (typeof result === 'object') {
newStatus = this.checkTerminusHealthResults([result]);
} else if (typeof result === 'boolean') {
newStatus = result;
}
} else {
this.statusMap[probeName] = true;
const results = await Promise.all(check.map(async (f) => await f()));
newStatus = this.checkTerminusHealthResults(results);
}

this.statusMap[probeName] = newStatus;
} else {
this.statusMap[probeName] = true;
}

return this.statusMap[probeName];
Expand Down

0 comments on commit 0501a02

Please sign in to comment.