Skip to content

Commit a38aa17

Browse files
committed
feat: throw error
1 parent 9c5dbb2 commit a38aa17

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed
Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Controller, Get, Param } from '@nestjs/common';
1+
import { Controller, Get, HttpException, Param } from '@nestjs/common';
22
import { ApiTags } from '@nestjs/swagger';
33
import { BullMqClient } from '@gitroom/nestjs-libraries/bull-mq-transport-new/client';
44

@@ -8,7 +8,23 @@ export class MonitorController {
88
constructor(private _workerServiceProducer: BullMqClient) {}
99

1010
@Get('/queue/:name')
11-
getMessagesGroup(@Param('name') name: string) {
12-
return this._workerServiceProducer.checkForStuckWaitingJobs(name);
11+
async getMessagesGroup(@Param('name') name: string) {
12+
const { valid } =
13+
await this._workerServiceProducer.checkForStuckWaitingJobs(name);
14+
15+
if (valid) {
16+
return {
17+
status: 'success',
18+
message: `Queue ${name} is healthy.`,
19+
};
20+
}
21+
22+
throw new HttpException(
23+
{
24+
status: 'error',
25+
message: `Queue ${name} has stuck waiting jobs.`,
26+
},
27+
503
28+
);
1329
}
1430
}

0 commit comments

Comments
 (0)