Skip to content

Commit

Permalink
feat: metrics aggregator - reject new request if a request is already…
Browse files Browse the repository at this point in the history
… being processed
  • Loading branch information
dhawal1248 committed Jun 12, 2024
1 parent 69d9ca4 commit 6a0fe66
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/util/metricsAggregator.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,16 @@ class MetricsAggregator {
}

async aggregateMetrics() {

Check warning on line 74 in src/util/metricsAggregator.js

View check run for this annotation

Codecov / codecov/patch

src/util/metricsAggregator.js#L74

Added line #L74 was not covered by tests
// If a request is already being processed, reject the new request
// Use resolveFunc to check if a request is already being processed
if (this.resolveFunc !== null) {
logger.error(

Check warning on line 78 in src/util/metricsAggregator.js

View check run for this annotation

Codecov / codecov/patch

src/util/metricsAggregator.js#L78

Added line #L78 was not covered by tests
'[MetricsAggregator] Failed to serve /metrics request, a request is already being processed.',
);
throw new Error(

Check warning on line 81 in src/util/metricsAggregator.js

View check run for this annotation

Codecov / codecov/patch

src/util/metricsAggregator.js#L81

Added line #L81 was not covered by tests
'[MetricsAggregator] Currently processing a request, please try again later.',
);
}
return new Promise((resolve, reject) => {
this.resolveFunc = resolve;
this.rejectFunc = reject;
Expand Down

0 comments on commit 6a0fe66

Please sign in to comment.