feat: throw error
This commit is contained in:
parent
9c5dbb2b4f
commit
a38aa176e5
|
|
@ -1,4 +1,4 @@
|
|||
import { Controller, Get, Param } from '@nestjs/common';
|
||||
import { Controller, Get, HttpException, Param } from '@nestjs/common';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
import { BullMqClient } from '@gitroom/nestjs-libraries/bull-mq-transport-new/client';
|
||||
|
||||
|
|
@ -8,7 +8,23 @@ export class MonitorController {
|
|||
constructor(private _workerServiceProducer: BullMqClient) {}
|
||||
|
||||
@Get('/queue/:name')
|
||||
getMessagesGroup(@Param('name') name: string) {
|
||||
return this._workerServiceProducer.checkForStuckWaitingJobs(name);
|
||||
async getMessagesGroup(@Param('name') name: string) {
|
||||
const { valid } =
|
||||
await this._workerServiceProducer.checkForStuckWaitingJobs(name);
|
||||
|
||||
if (valid) {
|
||||
return {
|
||||
status: 'success',
|
||||
message: `Queue ${name} is healthy.`,
|
||||
};
|
||||
}
|
||||
|
||||
throw new HttpException(
|
||||
{
|
||||
status: 'error',
|
||||
message: `Queue ${name} has stuck waiting jobs.`,
|
||||
},
|
||||
503
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue