Skip to content

Commit

Permalink
Merge pull request #30 from baquan1708/feat/retry-task
Browse files Browse the repository at this point in the history
retry when the task fails
  • Loading branch information
koichimurakami authored Oct 11, 2024
2 parents f2c68c2 + 718fdcd commit ccb611b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/task/src/event/task.queue.event.handler.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { EventBus, EventHandler, IEventHandler } from '@mbc-cqrs-serverless/core'
import { Inject, Logger, OnModuleInit } from '@nestjs/common'
import { ConfigService } from '@nestjs/config'
import { ModuleRef } from '@nestjs/core'

import { TaskStatusEnum } from '../enums/status.enum'
Expand All @@ -18,15 +17,15 @@ export class TaskQueueEventHandler
private eventBus: EventBus

constructor(
private readonly configService: ConfigService,
private readonly moduleRef: ModuleRef,
private readonly taskService: TaskService,
@Inject(TASK_QUEUE_EVENT_FACTORY)
private readonly eventFactory: ITaskQueueEventFactory,
) {}

onModuleInit() {
if (!this.configService.get<boolean>('EVENT_SOURCE_DISABLED')) {
const enableEventSourceModule = process.env.EVENT_SOURCE_DISABLED !== 'true'
if (enableEventSourceModule) {
this.eventBus = this.moduleRef.get(EventBus, { strict: false })
}
}
Expand All @@ -53,6 +52,7 @@ export class TaskQueueEventHandler
await this.taskService.updateStatus(taskKey, TaskStatusEnum.FAILED, {
error,
})
throw error
}
}
}

0 comments on commit ccb611b

Please sign in to comment.