Added more logs for jobs.
This commit is contained in:
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
import { Processor, WorkerHost } from '@nestjs/bullmq';
|
import { OnQueueEvent, Processor, WorkerHost } from '@nestjs/bullmq';
|
||||||
import { Job } from 'bullmq';
|
import { Job } from 'bullmq';
|
||||||
import { PinoLogger } from 'nestjs-pino';
|
import { PinoLogger } from 'nestjs-pino';
|
||||||
import { GoogleSearchContext } from 'src/providers/contexts/google.search.context';
|
import { GoogleSearchContext } from 'src/providers/contexts/google.search.context';
|
||||||
@ -101,6 +101,44 @@ export class LibraryConsumer extends WorkerHost {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OnQueueEvent('failed')
|
||||||
|
onFailed(job: Job, err: Error) {
|
||||||
|
this.logger.error({
|
||||||
|
class: LibraryConsumer.name,
|
||||||
|
method: this.onFailed.name,
|
||||||
|
job: job,
|
||||||
|
msg: 'A library job failed.',
|
||||||
|
error: err,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@OnQueueEvent('paused')
|
||||||
|
onPaused() {
|
||||||
|
this.logger.info({
|
||||||
|
class: LibraryConsumer.name,
|
||||||
|
method: this.onPaused.name,
|
||||||
|
msg: 'Library jobs have been paused.',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@OnQueueEvent('resumed')
|
||||||
|
onResume(job: Job) {
|
||||||
|
this.logger.info({
|
||||||
|
class: LibraryConsumer.name,
|
||||||
|
method: this.onResume.name,
|
||||||
|
msg: 'Library jobs have resumed.',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@OnQueueEvent('waiting')
|
||||||
|
onWaiting(jobId: number | string) {
|
||||||
|
this.logger.info({
|
||||||
|
class: LibraryConsumer.name,
|
||||||
|
method: this.onWaiting.name,
|
||||||
|
msg: 'A library job is waiting...',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private toScore(book: BookSearchResultDto, series: CreateSeriesSubscriptionJobDto): ({ result: BookSearchResultDto, score: number }) {
|
private toScore(book: BookSearchResultDto, series: CreateSeriesSubscriptionJobDto): ({ result: BookSearchResultDto, score: number }) {
|
||||||
if (!book) {
|
if (!book) {
|
||||||
return {
|
return {
|
||||||
|
Reference in New Issue
Block a user